62 lines
1.6 KiB
C#
Raw Permalink Normal View History

2023-03-13 19:57:35 +04:00
using LawFirmContracts.BindingModels;
using LawFirmContracts.ViewModels;
using LawFirmDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
2023-05-02 20:17:55 +04:00
using System.Runtime.Serialization;
2023-03-13 19:57:35 +04:00
namespace LawFirmDatabaseImplement.Models
{
2023-05-02 20:17:55 +04:00
[DataContract]
public class Blank : IBlankModel
2023-03-13 19:57:35 +04:00
{
2023-05-02 20:17:55 +04:00
[DataMember]
public int Id { get; private set; }
2023-03-13 19:57:35 +04:00
[Required]
2023-05-02 20:17:55 +04:00
[DataMember]
public string BlankName { get; private set; } = string.Empty;
2023-03-13 19:57:35 +04:00
[Required]
2023-05-02 20:17:55 +04:00
[DataMember]
public double Price { get; set; }
2023-03-13 19:57:35 +04:00
[ForeignKey("BlankId")]
public virtual List<DocumentBlank> DocumentBlanks { get; set; } = new();
public static Blank? Create(BlankBindingModel model)
{
if (model == null)
{
return null;
}
return new Blank()
{
Id = model.Id,
BlankName = model.BlankName,
Price = model.Price
};
}
public static Blank Create(BlankViewModel model)
{
return new Blank
{
Id = model.Id,
BlankName = model.BlankName,
Price = model.Price
};
}
public void Update(BlankBindingModel model)
{
if (model == null)
{
return;
}
BlankName = model.BlankName;
Price = model.Price;
}
public BlankViewModel GetViewModel => new()
{
Id = Id,
BlankName = BlankName,
Price = Price
};
}
}