ISEbd-21_Putilin_P.A._Preca.../PrecastConcretePlant/PrecastConcretePlantListImplement/Reinforced.cs

50 lines
1.5 KiB
C#
Raw Normal View History

2023-02-05 21:07:54 +04:00
using PrecastConcretePlantContracts.BindingModels;
using PrecastConcretePlantContracts.ViewModels;
using PrecastConcretePlantDataModels.Models;
namespace PrecastConcretePlantListImplement.Models
{
public class Reinforced : IReinforcedModel
{
public int Id { get; private set; }
public string ReinforcedName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, (IComponentModel, int)> ReinforcedComponents
{
get;
private set;
} = new Dictionary<int, (IComponentModel, int)>();
public static Reinforced? Create(ReinforcedBindingModel? model)
{
if (model == null)
{
return null;
}
return new Reinforced()
{
Id = model.Id,
ReinforcedName = model.ReinforcedName,
Price = model.Price,
ReinforcedComponents = model.ReinforcedComponents
};
}
public void Update(ReinforcedBindingModel? model)
{
if (model == null)
{
return;
}
ReinforcedName = model.ReinforcedName;
Price = model.Price;
ReinforcedComponents = model.ReinforcedComponents;
}
public ReinforcedViewModel GetViewModel => new()
{
Id = Id,
ReinforcedName = ReinforcedName,
Price = Price,
ReinforcedComponents = ReinforcedComponents
};
}
}