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 RepairComponents { get; private set; } = new Dictionary(); 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 }; } }