using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.ViewModels; using ConfectioneryDataModels; using ConfectioneryDataModels.Models; namespace ConfectioneryListImplement { public class Shop : IShopModel { public string Name { get; private set; } = string.Empty; public string Address { get; private set; } = string.Empty; public int MaxCountPastries { get; private set; } public DateTime DateOpening { get; private set; } public Dictionary Pastries { get; private set; } = new(); public int Id { get; private set; } public static Shop? Create(ShopBindingModel? model) { if (model == null) { return null; } return new Shop() { Id = model.Id, Name = model.Name, Address = model.Address, DateOpening = model.DateOpening, MaxCountPastries = model.MaxCountPastries, Pastries = new() }; } public void Update(ShopBindingModel? model) { if (model == null) { return; } Name = model.Name; Address = model.Address; DateOpening = model.DateOpening; MaxCountPastries = model.MaxCountPastries; Pastries = model.Pastries; } public ShopViewModel GetViewModel => new() { Id = Id, Name = Name, Address = Address, Pastries = Pastries, DateOpening = DateOpening, MaxCountPastries = MaxCountPastries, }; } }