56 lines
1.5 KiB
C#
56 lines
1.5 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
|
|
{
|
|
internal class Law : ILawModel
|
|
{
|
|
public int Id { get; private set; }
|
|
public string LawName { get; private set; } = string.Empty;
|
|
public double Price { get; private set; }
|
|
public Dictionary<int, (IComponentModel, int)> LawComponents
|
|
{
|
|
get;
|
|
private set;
|
|
} = new Dictionary<int, (IComponentModel, int)>();
|
|
public static Law? Create(LawBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Law()
|
|
{
|
|
Id = model.Id,
|
|
LawName = model.LawName,
|
|
Price = model.Price,
|
|
LawComponents = model.LawComponents
|
|
};
|
|
}
|
|
public void Update(LawBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
LawName = model.LawName;
|
|
Price = model.Price;
|
|
LawComponents = model.LawComponents;
|
|
}
|
|
public LawViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
LawName = LawName,
|
|
Price = Price,
|
|
LawComponents = LawComponents
|
|
};
|
|
|
|
}
|
|
}
|