65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
|
using GiftShopContracts.BindingModels;
|
|||
|
using GiftShopContracts.ViewModels;
|
|||
|
using GiftShopDataModels.Models;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace GiftShopListImplement.Models
|
|||
|
{
|
|||
|
public class Shop : IShopModel
|
|||
|
{
|
|||
|
public int Id { get; set; }
|
|||
|
public string ShopName { get; private set; } = string.Empty;
|
|||
|
public string ShopAdress { get; private set; } = string.Empty;
|
|||
|
|
|||
|
public DateTime OpeningDate { get; private set; }
|
|||
|
|
|||
|
public int MaxCapacity { get; private set; }
|
|||
|
|
|||
|
public Dictionary<int, (IGiftModel, int)> ShopGifts { get; private set; } = new();
|
|||
|
|
|||
|
public static Shop? Create(ShopBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Shop()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
ShopName = model.ShopName,
|
|||
|
ShopAdress = model.ShopAdress,
|
|||
|
OpeningDate = model.OpeningDate,
|
|||
|
MaxCapacity = model.MaxCapacity,
|
|||
|
ShopGifts = new()
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(ShopBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
ShopName = model.ShopName;
|
|||
|
ShopAdress = model.ShopAdress;
|
|||
|
OpeningDate = model.OpeningDate;
|
|||
|
MaxCapacity = model.MaxCapacity;
|
|||
|
ShopGifts = model.ShopGifts;
|
|||
|
}
|
|||
|
|
|||
|
public ShopViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
ShopName = ShopName,
|
|||
|
ShopAdress = ShopAdress,
|
|||
|
OpeningDate = OpeningDate,
|
|||
|
MaxCapacity = MaxCapacity,
|
|||
|
ShopGifts = ShopGifts
|
|||
|
};
|
|||
|
}
|
|||
|
}
|