56 lines
1.6 KiB
C#
Raw Normal View History

2024-04-13 01:58:54 +04:00
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
{
2024-05-10 23:48:48 +04:00
public class Document : IDocumentModel
2024-04-13 01:58:54 +04:00
{
public int Id { get; private set; }
2024-05-10 23:48:48 +04:00
public string DocumentName { get; private set; } = string.Empty;
2024-04-13 01:58:54 +04:00
public double Price { get; private set; }
2024-05-10 23:48:48 +04:00
public Dictionary<int, (IComponentModel, int)> DocumentComponents
2024-04-13 01:58:54 +04:00
{
get;
private set;
} = new Dictionary<int, (IComponentModel, int)>();
2024-05-10 23:48:48 +04:00
public static Document? Create(DocumentBindingModel? model)
2024-04-13 01:58:54 +04:00
{
if (model == null)
{
return null;
}
2024-05-10 23:48:48 +04:00
return new Document()
2024-04-13 01:58:54 +04:00
{
2024-05-10 23:48:48 +04:00
2024-04-13 01:58:54 +04:00
Id = model.Id,
2024-05-10 23:48:48 +04:00
DocumentName = model.DocumentName,
2024-04-13 01:58:54 +04:00
Price = model.Price,
2024-05-10 23:48:48 +04:00
DocumentComponents = model.DocumentComponents
2024-04-13 01:58:54 +04:00
};
}
2024-05-10 23:48:48 +04:00
public void Update(DocumentBindingModel? model)
2024-04-13 01:58:54 +04:00
{
if (model == null)
{
return;
}
2024-05-10 23:48:48 +04:00
DocumentName = model.DocumentName;
2024-04-13 01:58:54 +04:00
Price = model.Price;
2024-05-10 23:48:48 +04:00
DocumentComponents = model.DocumentComponents;
2024-04-13 01:58:54 +04:00
}
2024-05-10 23:48:48 +04:00
public DocumentViewModel GetViewModel => new()
2024-04-13 01:58:54 +04:00
{
Id = Id,
2024-05-10 23:48:48 +04:00
DocumentName = DocumentName,
2024-04-13 01:58:54 +04:00
Price = Price,
2024-05-10 23:48:48 +04:00
DocumentComponents = DocumentComponents
2024-04-13 01:58:54 +04:00
};
}
}