50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
|
using CarRepairShopContracts.BindingModels;
|
|||
|
using CarRepairShopContracts.ViewModels;
|
|||
|
using CarRepairShopDataModels.Models;
|
|||
|
|
|||
|
namespace CarRepairShopListImplement.Models
|
|||
|
{
|
|||
|
public class Repair : IRepairModel
|
|||
|
{
|
|||
|
public int Id { get; private set; }
|
|||
|
public string RepairName { get; private set; } = string.Empty;
|
|||
|
public double Price { get; private set; }
|
|||
|
public Dictionary<int, (IComponentModel, int)> RepairComponents
|
|||
|
{
|
|||
|
get;
|
|||
|
private set;
|
|||
|
} = new Dictionary<int, (IComponentModel, int)>();
|
|||
|
public static Repair? Create(RepairBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Repair()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
RepairName = model.RepairName,
|
|||
|
Price = model.Price,
|
|||
|
RepairComponents = model.RepairComponents
|
|||
|
};
|
|||
|
}
|
|||
|
public void Update(RepairBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
RepairName = model.RepairName;
|
|||
|
Price = model.Price;
|
|||
|
RepairComponents = model.RepairComponents;
|
|||
|
}
|
|||
|
public RepairViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
RepairName = RepairName,
|
|||
|
Price = Price,
|
|||
|
RepairComponents = RepairComponents
|
|||
|
};
|
|||
|
}
|
|||
|
}
|