PIbd-21_Markov_D.P._LawFirm/LawFirm/LawFirmListImplement/Models/Document.cs

51 lines
1.4 KiB
C#
Raw Normal View History

2023-02-13 22:22:24 +04:00
using LawFirmContracts.BindingModels;
using LawFirmContracts.ViewModels;
using LawFirmDataModels.Models;
namespace LawFirmListImplement.Models
{
public class Document : IDocumentModel
{
public int Id { get; private set; }
public string DocumentName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, (IBlankModel, int)> DocumentBlanks
{
get;
private set;
} = new Dictionary<int, (IBlankModel, int)>();
public static Document? Create(DocumentBindingModel? model)
{
if (model == null)
{
return null;
}
return new Document()
{
Id = model.Id,
DocumentName = model.DocumentName,
Price = model.Price,
DocumentBlanks = model.DocumentBlanks
};
}
public void Update(DocumentBindingModel? model)
{
if (model == null)
{
return;
}
DocumentName = model.DocumentName;
Price = model.Price;
DocumentBlanks = model.DocumentBlanks;
}
public DocumentViewModel GetViewModel => new()
{
Id = Id,
DocumentName = DocumentName,
Price = Price,
DocumentBlanks = DocumentBlanks
};
}
}