using JewelryStoreDataModels.Models;
using JewelryStoreContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JewelryStoreContracts.BindingModels;

namespace JewelryStoreListImplement.Models
{
    public class Jewel: IJewelModel
    {
        public int Id { get; private set; }
        public string JewelName { get; private set; } = string.Empty;
        public double Price { get; private set; }
        public Dictionary<int, (IComponentModel, int)> JewelComponents
        {
            get;
            private set;
        } = new Dictionary<int, (IComponentModel, int)>();
        public static Jewel? Create(JewelBindingModel? model)
        {
            if (model == null)
            {
                return null;
            }
            return new Jewel()
            {
                Id = model.Id,
                JewelName = model.JewelName,
                Price = model.Price,
                JewelComponents = model.JewelComponents
            };
        }
        public void Update(JewelBindingModel? model)
        {
            if (model == null)
            {
                return;
            }
            JewelName = model.JewelName;
            Price = model.Price;
            JewelComponents = model.JewelComponents;
        }
        public JewelViewModel GetViewModel => new()
        {
            Id = Id,
            JewelName = JewelName,
            Price = Price,
            JewelComponents = JewelComponents
        };

    }
}
