59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
|
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 DateTime DateOpening { get; private set; }
|
|||
|
|
|||
|
public Dictionary<int, (IPastryModel, int)> 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,
|
|||
|
Pastries = model.Pastries
|
|||
|
};
|
|||
|
}
|
|||
|
public void Update(ShopBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
Name = model.Name;
|
|||
|
Address = model.Address;
|
|||
|
DateOpening = model.DateOpening;
|
|||
|
Pastries = model.Pastries;
|
|||
|
}
|
|||
|
public ShopViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
Name = Name,
|
|||
|
Address = Address,
|
|||
|
Pastries = Pastries
|
|||
|
};
|
|||
|
}
|
|||
|
}
|