Добавлена модель магазина в проект по хранению данных
This commit is contained in:
parent
057693daef
commit
a0486f0392
54
SecuritySystem/SecuritySystemListImplement/Models/Shop.cs
Normal file
54
SecuritySystem/SecuritySystemListImplement/Models/Shop.cs
Normal 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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user