using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PrecastConcretePlantContracts.BindingModels;
using PrecastConcretePlantContracts.ViewModels;
using PrecastConcretePlantDataModels.Models;

namespace PrecastConcretePlantListImplement.Models
{
    public class Reinforced : IReinforcedModel
    {
        public int Id { get; private set; }
        public string ReinforcedName { get; private set; } = string.Empty;
        public double Price { get; private set; }
        public Dictionary<int, (IComponentModel, int)> ReinforcedComponents
        {
            get;
            private set;
        } = new Dictionary<int, (IComponentModel, int)>();
        public static Reinforced? Create(ReinforcedBindingModel? model)
        {
            if (model == null)
            {
                return null;
            }
            return new Reinforced()
            {

            Id = model.Id,
            ReinforcedName = model.ReinforcedName,
            Price = model.Price,
            ReinforcedComponents = model.ReinforcedComponents
            };
        }
        public void Update(ReinforcedBindingModel? model)
        {
            if (model == null)
            {
                return;
            }
            ReinforcedName = model.ReinforcedName;
            Price = model.Price;
            ReinforcedComponents = model.ReinforcedComponents;
        }
        public ReinforcedViewModel GetViewModel => new()
        {
            Id = Id,
            ReinforcedName = ReinforcedName,
            Price = Price,
            ReinforcedComponents = ReinforcedComponents
        };
    }
}
