61 lines
1.6 KiB
C#
61 lines
1.6 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 string ShopName { get; private set; } = string.Empty;
|
|
public string ShopAddress { get; private set; } = string.Empty;
|
|
|
|
public DateTime OpeningDate { get; private set; }
|
|
|
|
public Dictionary<int, (IGiftModel, int)> Gifts { 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,
|
|
ShopName = model.ShopName,
|
|
ShopAddress = model.ShopAddress,
|
|
OpeningDate = model.OpeningDate,
|
|
Gifts = new()
|
|
};
|
|
}
|
|
|
|
public void Update(ShopBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
ShopName = model.ShopName;
|
|
ShopAddress = model.ShopAddress;
|
|
OpeningDate = model.OpeningDate;
|
|
Gifts = model.Gifts;
|
|
}
|
|
|
|
public ShopViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
ShopName = ShopName,
|
|
ShopAddress = ShopAddress,
|
|
OpeningDate = OpeningDate,
|
|
Gifts = Gifts
|
|
};
|
|
}
|
|
}
|