using BlacksmithWorkshopContracts.BindingModels;
using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BlacksmithWorkshopListImplement.Models
{
    public class Manufacture : IManufactureModel
    {
        public int Id { get; private set; }
        public string ManufactureName { get; private set; } = string.Empty;
        public double Price { get; private set; }
        public Dictionary<int, (IComponentModel, int)> ManufactureComponents
        {
            get;
            private set;
        } = new Dictionary<int, (IComponentModel, int)>();
        public static Manufacture? Create(ManufactureBindingModel? model)
        {
            if (model == null)
            {
                return null;
            }
            return new Manufacture()
            {
                Id = model.Id,
                ManufactureName = model.ManufactureName,
                Price = model.Price,
                ManufactureComponents = model.ManufactureComponents
            };
        }
        public void Update(ManufactureBindingModel? model)
        {
            if (model == null)
            {
                return;
            }
            ManufactureName = model.ManufactureName;
            Price = model.Price;
            ManufactureComponents = model.ManufactureComponents;
        }
        public ManufactureViewModel GetViewModel => new()
        {
            Id = Id,
            ManufactureName = ManufactureName,
            Price = Price,
            ManufactureComponents = ManufactureComponents
        };
    }
}
