57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
|
using LawFirmContracts.BindingModels;
|
|||
|
using LawFirmContracts.ViewModels;
|
|||
|
using LawFirmDataModels.Models;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using System.ComponentModel.DataAnnotations.Schema;
|
|||
|
|
|||
|
namespace LawFirmDatabaseImplement.Models
|
|||
|
{
|
|||
|
public class Blank : IBlankModel
|
|||
|
{
|
|||
|
public int Id { get; private set; }
|
|||
|
[Required]
|
|||
|
public string BlankName { get; private set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public double Price { get; set; }
|
|||
|
[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
|
|||
|
};
|
|||
|
}
|
|||
|
}
|