using AbstractIceCreamShopDataModels.Models;
using IceCreamShopContracts.BindingModels;
using IceCreamShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IceCreamShopListImplement.Models
{
    public class Shop : IShopModel
    {
        public int Id { get; private set; }

        public string Name { get; private set; } = string.Empty;

        public string Adress { get; private set; } = string.Empty;

        public DateTime OpeningDate { get; private set; }

        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,
                Name = model.Name,
                Adress = model.Adress,
                OpeningDate = model.OpeningDate,
                ShopIceCreams = new()
            };
        }

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

        public ShopViewModel GetViewModel => new()
        {
            Id = Id,
            Name = Name,
            Adress = Adress,
            OpeningDate = OpeningDate,
            ShopIceCreams = ShopIceCreams
        };

        public int IceCreamMaxCount => throw new NotImplementedException();
    }
}
