ISEbd-21_Chegodaev_A.Y._Law.../LawFirm/LawFirmListImplement/Models/Document.cs
aleksandr chegodaev 39c1538546 lab4
2024-05-10 23:48:48 +04:00

56 lines
1.6 KiB
C#

using LawFirmContracts.BindingModels;
using LawFirmContracts.ViewModels;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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, (IComponentModel, int)> DocumentComponents
{
get;
private set;
} = new Dictionary<int, (IComponentModel, int)>();
public static Document? Create(DocumentBindingModel? model)
{
if (model == null)
{
return null;
}
return new Document()
{
Id = model.Id,
DocumentName = model.DocumentName,
Price = model.Price,
DocumentComponents = model.DocumentComponents
};
}
public void Update(DocumentBindingModel? model)
{
if (model == null)
{
return;
}
DocumentName = model.DocumentName;
Price = model.Price;
DocumentComponents = model.DocumentComponents;
}
public DocumentViewModel GetViewModel => new()
{
Id = Id,
DocumentName = DocumentName,
Price = Price,
DocumentComponents = DocumentComponents
};
}
}