using SushiBarContracts.BindingModels; using SushiBarContracts.ViewModels; using SushiBarDataModels.Models; namespace SushiBarListImplement.Models { public class Shop : IShopModel { public int Id { get; set; } public string ShopName { get; private set; } = string.Empty; public string Address { get; private set; } = string.Empty; public DateTime DateCreate { get; private set; } public Dictionary ShopSushi { get; private set; } = new Dictionary(); public static Shop? Create(ShopBindingModel? model) { if (model == null) { return null; } return new Shop() { Id = model.Id, ShopName = model.ShopName, Address = model.Address, DateCreate = model.DateCreate, ShopSushi = model.ShopSushi }; } public void Update(ShopBindingModel? model) { if (model == null) { return; } ShopName = model.ShopName; Address = model.Address; DateCreate = model.DateCreate; ShopSushi = model.ShopSushi; } public ShopViewModel GetViewModel => new() { Id = Id, ShopName = ShopName, Address = Address, DateCreate = DateCreate, }; } }