46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using MotorPlantContracts.BindingModels;
|
|
using MotorPlantContracts.VeiwModels;
|
|
using MotorPlantDataModels.Models;
|
|
|
|
namespace MotorPlantListImplement.Models
|
|
{
|
|
public class Engine : IEngineModel
|
|
{
|
|
public int Id { get; private set; }
|
|
public string EngineName { get; private set; } = string.Empty;
|
|
public double Price { get; private set; }
|
|
public Dictionary<int, (IComponentModel, int)> EngineComponents { get; private set; } = new Dictionary<int, (IComponentModel, int)>();
|
|
public static Engine? Create(EngineBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Engine()
|
|
{
|
|
Id = model.Id,
|
|
EngineName = model.EngineName,
|
|
Price = model.Price,
|
|
EngineComponents = model.EngineComponents
|
|
};
|
|
}
|
|
public void Update(EngineBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
EngineName = model.EngineName;
|
|
Price = model.Price;
|
|
EngineComponents = model.EngineComponents;
|
|
}
|
|
public EngineViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
EngineName = EngineName,
|
|
Price = Price,
|
|
EngineComponents = EngineComponents
|
|
};
|
|
}
|
|
}
|