using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TIAM.Core.Enums;
using TIAM.Entities.Products;
using TIAM.Entities.ServiceProviders;
using TIAM.Resources;

namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
{
    public class ProductWizardModel
    {
        public Guid Id { get; set; }
        [Required(ErrorMessage = "The type of service should be specified.")]
        [DataType("ProductType")]
        [Display(Name = ResourceKeys.ProductType, ResourceType = typeof(TIAMResources))]
        public ProductType ProductType { get; set; }
        //public Guid? UserMediaId { get; set; }
        [Required(ErrorMessage = "The name should be specified.")]
        [DataType(DataType.Text)]
        [Display(Name = ResourceKeys.ProductName, ResourceType = typeof(TIAMResources))]
        public string Name { get; set; }
        [Required(ErrorMessage = "The description should be specified.")]
        [DataType(DataType.MultilineText)]
        [Display(Name = ResourceKeys.ProductDescription, ResourceType = typeof(TIAMResources))]
        public string Description { get; set; }

        public float Price { get; set; }
        public string? JsonDetails { get; set; }

        public TiamServiceProvider TiamServiceProvider { get; set; }

        public ProductWizardModel() { }

        public ProductWizardModel(TiamServiceProvider tiamServiceProvider, ProductType productType, string name, string description, float price, string? jsonDetails) : this(Guid.NewGuid(), tiamServiceProvider, productType, name, description, price, jsonDetails) { }      

        public ProductWizardModel(Guid id, TiamServiceProvider tiamServiceProvider, ProductType productType, string name, string description, float price, string? jsonDetails)
        {
            Id = id;
            TiamServiceProvider = tiamServiceProvider;
            ProductType = productType;
            Name = name;
            Description = description;
            Price = price;
            JsonDetails = jsonDetails;
        }

        public Product SaveToProduct(TiamServiceProvider tiamServiceProvider)
        {
            Product NewProduct = new(this.Id, tiamServiceProvider.Id, tiamServiceProvider, this.ProductType, this.Name, this.Description, this.Price, this.JsonDetails);
            return NewProduct;
        }
    }
}
