using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SushiBarListImplement.Models
{
    public class Shop : IShopModel
    {
        public int Id { get; private set; }
    public string ShopName { get; private set; } = string.Empty;
    public string Adress { get; private set; } = string.Empty;
    public DateTime OpeningDate { get; private set; }
    public Dictionary<int, (ISushiModel, int)> ShopSushis { get; private set; } = new();
    public int SushiMaxCount { get; private set; }

    public static Shop? Create(ShopBindingModel? model)
    {
        if (model == null)
        {
            return null;
        }
        return new Shop()
        {
            Id = model.Id,
            ShopName = model.ShopName,
            Adress = model.Adress,
            OpeningDate = model.OpeningDate,
            SushiMaxCount = model.SushiMaxCount,
        };
    }

    public void Update(ShopBindingModel? model)
    {
        if (model == null)
        {
            return;
        }
        ShopName = model.ShopName;
        Adress = model.Adress;
        OpeningDate = model.OpeningDate;
        SushiMaxCount = model.SushiMaxCount;
    }

    public ShopViewModel GetViewModel => new()
    {
        Id = Id,
        ShopName = ShopName,
        Adress = Adress,
        OpeningDate = OpeningDate,
        ShopSushis = ShopSushis,
        SushiMaxCount = SushiMaxCount,
    };
}
}
