using ComputersShopContracts.BindingModels; using ComputersShopContracts.ViewModels; using ComputersShopDataModels.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ComputersShopListImplement.Models { public class Shop : IShopModel { public string ShopName { get; private set; } = string.Empty; public string ShopAddress { get; private set; } = string.Empty; public DateTime DateOpening { get; private set; } public Dictionary Computers { 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, ShopName = model.ShopName, ShopAddress = model.ShopAddress, DateOpening = model.DateOpening, Computers = new() }; } public void Update(ShopBindingModel? model) { if (model == null) { return; } ShopName = model.ShopName; ShopAddress = model.ShopAddress; DateOpening = model.DateOpening; Computers = model.Computers; } public ShopViewModel GetViewModel => new() { Id = Id, ShopName = ShopName, ShopAddress = ShopAddress, DateOpening = DateOpening, Computers = Computers }; } }