PIbd-23-Yunusov-N.N.-CarRep.../CarRepairShop/CarRepairShopListImplement/Models/Shop.cs
2024-02-13 00:17:40 +04:00

52 lines
1.5 KiB
C#

using CarRepairShopContracts.BindingModels;
using CarRepairShopContracts.ViewModels;
using CarRepairShopDataModels;
using CarRepairShopDataModels.Models;
namespace CarRepairShopListImplement.Models
{
public class Shop : IShopModel
{
public int Id { get; private set; }
public string ShopName { get; private set; }
public string Address { get; private set; }
public DateTime DateOpen { get; private set; }
public Dictionary<int, (IRepairModel, int)> ShopRepairs { get; private set; } = new();
public static Shop? Create(ShopBindingModel model)
{
if (model == null)
return null;
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Address = model.Address,
DateOpen = model.DateOpen,
ShopRepairs = new()
};
}
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
ShopName = model.ShopName;
Address = model.Address;
DateOpen = model.DateOpen;
ShopRepairs = model.ShopRepairs;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Address = Address,
DateOpen = DateOpen,
ShopRepairs = ShopRepairs
};
}
}