57 lines
1.4 KiB
C#
57 lines
1.4 KiB
C#
|
using LawFirmContracts.BindingModels;
|
|||
|
using LawFirmContracts.ViewModels;
|
|||
|
using LawFirmDataModels.Models;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using System.ComponentModel.DataAnnotations.Schema;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
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 Cost { 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,
|
|||
|
Cost = model.Cost
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(BlankBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
BlankName = model.BlankName;
|
|||
|
Cost = model.Cost;
|
|||
|
}
|
|||
|
public BlankViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
BlankName = BlankName,
|
|||
|
Cost = Cost
|
|||
|
};
|
|||
|
}
|
|||
|
}
|