PIbd-21 Potapov N.S. LabWork02 Hard #9

Closed
ns.potapov wants to merge 34 commits from LabWorkHard02 into LabWork02
Showing only changes of commit a0486f0392 - Show all commits

View File

@ -0,0 +1,54 @@
using SecuritySystemContracts.BindingModels;
using SecuritySystemContracts.ViewModels;
using SecuritySystemDataModels.Models;
namespace SecuritySystemListImplement.Models
{
public class Shop : IShopModel
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public DateTime OpeningDate { get; private set; }
public Dictionary<int, (ISecureModel, int)> ShopSecures { get; private set; } = new();
public static Shop? Create(ShopBindingModel model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
Name = model.Name,
Address = model.Address,
OpeningDate = model.OpeningDate,
ShopSecures = new()
};
}
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
Name = model.Name;
Address = model.Address;
OpeningDate = model.OpeningDate;
ShopSecures = model.ShopSecures;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Address = Address,
OpeningDate = OpeningDate,
ShopSecures = ShopSecures
};
}
}