using SecureShopContracts.BindingModels;
using SecureShopContracts.ViewModels;
using SecureShopDataModels.Models;

namespace SecureShopListImplement.Models
{
    public class Secure : ISecureModel
    {
        public int Id { get; private set; }
        public string SecureName { get; private set; } = string.Empty;
        public double Price { get; private set; }
        public Dictionary<int, (IFacilitiesModel, int)> SecureFacilitiess{ get; private set; } = new Dictionary<int, (IFacilitiesModel, int)>();
        
        public static Secure? Create(SecureBindingModel? model)
        {
            if (model == null)
            {
                return null;
            }
            return new Secure()
            {
                Id = model.Id,
                SecureName = model.SecureName,
                Price = model.Price,
                SecureFacilitiess = model.SecureFacilitiess
            };
        }

        public void Update(SecureBindingModel? model)
        {
            if (model == null)
            {
                return;
            }
            SecureName = model.SecureName;
            Price = model.Price;
            SecureFacilitiess = model.SecureFacilitiess;
        }

        public SecureViewModel GetViewModel => new()
        {
            Id = Id,
            SecureName = SecureName,
            Price = Price,
            SecureFacilitiess = SecureFacilitiess
        };
    }
}