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 IceCream : IIceCreamModel
    {
        public int Id { get; private set; }
        public string IceCreamName { get; private set; } = string.Empty;
        public double Price { get; private set; }
        public Dictionary<int, (IComponentModel, int)> IceCreamComponents
        {
            get;
            private set;
        } = new Dictionary<int, (IComponentModel, int)>();
        public static IceCream? Create(IceCreamBindingModel? model)
        {
            if (model == null)
            {
                return null;
            }
            return new IceCream()
            {
                Id = model.Id,
                IceCreamName = model.IceCreamName,
                Price = model.Price,
                IceCreamComponents = model.IceCreamComponents
            };
        }
        public void Update(IceCreamBindingModel? model)
        {
            if (model == null)
            {
                return;
            }
            IceCreamName = model.IceCreamName;
            Price = model.Price;
            IceCreamComponents = model.IceCreamComponents;
        }
        public IceCreamViewModel GetViewModel => new()
        {
            Id = Id,
            IceCreamName = IceCreamName,
            Price = Price,
            IceCreamComponents = IceCreamComponents
        };
    }
}
