2024-02-07 16:24:04 +04:00
|
|
|
|
using IceCreamShopContracts.BindingModels;
|
|
|
|
|
using IceCreamShopContracts.ViewModels;
|
|
|
|
|
using IceCreamShopDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace IceCreamShopListImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Shop : IShopModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
public string ShopName { get; private set; }
|
|
|
|
|
public string Address { get; private set; }
|
|
|
|
|
public DateTime DateOpen { get; private set; }
|
2024-03-04 15:28:55 +04:00
|
|
|
|
public int MaxCapacity { get; private set; }
|
2024-02-07 16:24:04 +04:00
|
|
|
|
public Dictionary<int, (IIceCreamModel, int)> ShopIceCreams { get; private set; } = new();
|
|
|
|
|
|
|
|
|
|
public static Shop? Create (ShopBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
return null;
|
|
|
|
|
return new Shop()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
ShopName = model.ShopName,
|
|
|
|
|
Address = model.Address,
|
|
|
|
|
DateOpen = model.DateOpen,
|
|
|
|
|
ShopIceCreams = new()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(ShopBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ShopName = model.ShopName;
|
|
|
|
|
Address = model.Address;
|
|
|
|
|
DateOpen = model.DateOpen;
|
|
|
|
|
ShopIceCreams = model.ShopIceCreams;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ShopViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
ShopName = ShopName,
|
|
|
|
|
Address = Address,
|
|
|
|
|
DateOpen = DateOpen,
|
|
|
|
|
ShopIceCreams = ShopIceCreams
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|