using System.ComponentModel.DataAnnotations;
using Kreta.BusinessLogic.HelperClasses;
using Kreta.Resources;

namespace Kreta.Web.Areas.Intezmeny.Models
{
    public class TeremSearchModel
    {
        [Display(Name = nameof(IntezmenyResource.HelyisegNev), ResourceType = typeof(IntezmenyResource))]
        public string TeremNev { get; set; }

        [Display(Name = nameof(IntezmenyResource.HelyisegJelleg), ResourceType = typeof(IntezmenyResource))]
        public int? TeremJellegID { get; set; }

        [Display(Name = nameof(IntezmenyResource.MukodesiHely), ResourceType = typeof(IntezmenyResource))]
        public int? KeresesMukodesiHelyID { get; set; }

        [Display(Name = nameof(IntezmenyResource.AlapteruletTolIg), ResourceType = typeof(IntezmenyResource))]
        [Range(1, 9999, ErrorMessageResourceName = nameof(IntezmenyResource.Alapterulet1Tol9999), ErrorMessageResourceType = typeof(IntezmenyResource))]
        public int? MinAlapterulet { get; set; }

        [Display(Name = nameof(IntezmenyResource.AlapteruletTolIg), ResourceType = typeof(IntezmenyResource))]
        [Range(1, 9999, ErrorMessageResourceName = nameof(IntezmenyResource.Alapterulet1Tol9999), ErrorMessageResourceType = typeof(IntezmenyResource))]
        public int? MaxAlapterulet { get; set; }

        [Display(Name = nameof(IntezmenyResource.BefogadoKepessegTolIg), ResourceType = typeof(IntezmenyResource))]
        [Range(0, 5000, ErrorMessageResourceName = nameof(IntezmenyResource.BefogadoKepessegeg0tol5000), ErrorMessageResourceType = typeof(IntezmenyResource))]
        public int? MinKapacitas { get; set; }

        [Display(Name = nameof(IntezmenyResource.BefogadoKepessegTolIg), ResourceType = typeof(IntezmenyResource))]
        [Range(0, 5000, ErrorMessageResourceName = nameof(IntezmenyResource.BefogadoKepessegeg0tol5000), ErrorMessageResourceType = typeof(IntezmenyResource))]
        public int? MaxKapacitás { get; set; }

        [Display(Name = nameof(IntezmenyResource.Aktiv), ResourceType = typeof(IntezmenyResource))]
        public int? IsAktiv { get; set; }

        [Display(Name = nameof(IntezmenyResource.Teremfelelos), ResourceType = typeof(IntezmenyResource))]
        public int? TeremfelelosID { get; set; }

        [Display(Name = nameof(IntezmenyResource.VizsgaBefogadoKepessegTolIg), ResourceType = typeof(IntezmenyResource))]
        [Range(0, 5000, ErrorMessageResourceName = nameof(IntezmenyResource.VizsgaBefogadoKepesseg0Tol5000), ErrorMessageResourceType = typeof(IntezmenyResource))]
        public int? MinVizsgaKapacitas { get; set; }

        [Display(Name = nameof(IntezmenyResource.VizsgaBefogadoKepessegTolIg), ResourceType = typeof(IntezmenyResource))]
        [Range(0, 5000, ErrorMessageResourceName = nameof(IntezmenyResource.VizsgaBefogadoKepesseg0Tol5000), ErrorMessageResourceType = typeof(IntezmenyResource))]
        public int? MaxVizsgaKapacitas { get; set; }

        [Display(Name = nameof(IntezmenyResource.EgyszerreTobbOratLehetTartani), ResourceType = typeof(IntezmenyResource))]
        public int? IsTobbOraTarthato { get; set; }

        [Display(Name = nameof(IntezmenyResource.WifiElerheto), ResourceType = typeof(IntezmenyResource))]
        public int? IsWifiLefedett { get; set; }

        [Display(Name = nameof(IntezmenyResource.IsInternetkapcsolatElerheto), ResourceType = typeof(IntezmenyResource))]
        public int? IsInternetkapcsolatElerheto { get; set; }

        [Display(Name = nameof(IntezmenyResource.OktCelraHasznaltSzamitogepekSzamaTolIg), ResourceType = typeof(IntezmenyResource))]
        [Range(0, 5000, ErrorMessageResourceName = nameof(IntezmenyResource.OktCelraHasznaltSzamitogepekSzama0Tol5000), ErrorMessageResourceType = typeof(IntezmenyResource))]
        public int? MinOktCelraHasznaltSzamitogepekSzama { get; set; }

        [Display(Name = nameof(IntezmenyResource.OktCelraHasznaltSzamitogepekSzamaTolIg), ResourceType = typeof(IntezmenyResource))]
        [Range(0, 5000, ErrorMessageResourceName = nameof(IntezmenyResource.OktCelraHasznaltSzamitogepekSzama0Tol5000), ErrorMessageResourceType = typeof(IntezmenyResource))]
        public int? MaxOktCelraHasznaltSzamitogepekSzama { get; set; }

        [Display(Name = nameof(IntezmenyResource.IsInterakttablavalMunkaallomassalFelszerelt), ResourceType = typeof(IntezmenyResource))]
        public int? IsInterakttablavalMunkaallomassalFelszerelt { get; set; }

        public int? SzervezetId { get; set; }

        public bool IsFromSzervezet { get; set; } = false;

        [Display(Name = nameof(TeremResource.SzervezetNeve), ResourceType = typeof(TeremResource))]
        public string SzervezetNev { get; set; }

        [Display(Name = nameof(TeremResource.SzervezetAzonosito), ResourceType = typeof(TeremResource))]
        public string SzervezetAzonosito { get; set; }

        public string ControllerName { get; set; } = Constants.Controllers.Terem;

        public string ApiControllerName { get; set; } = Constants.ApiControllers.TeremApi;

        public static TeremSearchCO ConvertModelSearchToCO(TeremSearchModel teremSearchModel)
            => new TeremSearchCO()
            {
                TeremNev = teremSearchModel.TeremNev,
                TeremJellegId = teremSearchModel.TeremJellegID,
                KeresesMukodesiHelyID = teremSearchModel.KeresesMukodesiHelyID,
                MinAlapterulet = teremSearchModel.MinAlapterulet,
                MaxAlapterulet = teremSearchModel.MaxAlapterulet,
                MinKapacitas = teremSearchModel.MinKapacitas,
                MaxKapacitas = teremSearchModel.MaxKapacitás,
                IsAktiv = teremSearchModel.IsAktiv,
                TeremFelelosId = teremSearchModel.TeremfelelosID,
                MinVizsgaKapacitas = teremSearchModel.MinVizsgaKapacitas,
                MaxVizsgaKapacitas = teremSearchModel.MaxVizsgaKapacitas,
                IsTobbOraTarthato = teremSearchModel.IsTobbOraTarthato,
                IsWifiLefedett = teremSearchModel.IsWifiLefedett,
                IsInternetkapcsolatElerheto = teremSearchModel.IsInternetkapcsolatElerheto,
                MinOktCelraHasznaltSzamitogepekSzama = teremSearchModel.MinOktCelraHasznaltSzamitogepekSzama,
                MaxOktCelraHasznaltSzamitogepekSzama = teremSearchModel.MaxOktCelraHasznaltSzamitogepekSzama,
                IsInterakttablavalMunkaallomassalFelszerelt = teremSearchModel.IsInterakttablavalMunkaallomassalFelszerelt,
                SzervezetId = teremSearchModel.SzervezetId,
                SzervezetNev = teremSearchModel.SzervezetNev,
                SzervezetAzonosito = teremSearchModel.SzervezetAzonosito,
            };

        public static TeremExportSearchCO ConvertModelToExportSearchCO(TeremSearchModel teremSearchModel)
            => new TeremExportSearchCO()
            {
                TeremNev = teremSearchModel.TeremNev,
                TeremJellegID = teremSearchModel.TeremJellegID,
                KeresesMukodesiHelyID = teremSearchModel.KeresesMukodesiHelyID,
                MinAlapterulet = teremSearchModel.MinAlapterulet,
                MaxAlapterulet = teremSearchModel.MaxAlapterulet,
                MinKapacitas = teremSearchModel.MinKapacitas,
                MaxKapacitás = teremSearchModel.MaxKapacitás,
                IsAktiv = teremSearchModel.IsAktiv,
                TeremFelelosId = teremSearchModel.TeremfelelosID,
                MinVizsgaKapacitas = teremSearchModel.MinVizsgaKapacitas,
                MaxVizsgaKapacitas = teremSearchModel.MaxVizsgaKapacitas,
                IsTobbOraTarthato = teremSearchModel.IsTobbOraTarthato,
                IsWifiLefedett = teremSearchModel.IsWifiLefedett,
                IsInternetkapcsolatElerheto = teremSearchModel.IsInternetkapcsolatElerheto,
                MinOktCelraHasznaltSzamitogepekSzama = teremSearchModel.MinOktCelraHasznaltSzamitogepekSzama,
                MaxOktCelraHasznaltSzamitogepekSzama = teremSearchModel.MaxOktCelraHasznaltSzamitogepekSzama,
                IsInterakttablavalMunkaallomassalFelszerelt = teremSearchModel.IsInterakttablavalMunkaallomassalFelszerelt
            };

        public TeremSearchCO ConvertToCo()
        {
            return new TeremSearchCO()
            {
                TeremNev = this.TeremNev,
                TeremJellegId = this.TeremJellegID,
                KeresesMukodesiHelyID = this.KeresesMukodesiHelyID,
                MinAlapterulet = this.MinAlapterulet,
                MaxAlapterulet = this.MaxAlapterulet,
                MinKapacitas = this.MinKapacitas,
                MaxKapacitas = this.MaxKapacitás,
                IsAktiv = this.IsAktiv,
                TeremFelelosId = this.TeremfelelosID,
                MinVizsgaKapacitas = this.MinVizsgaKapacitas,
                MaxVizsgaKapacitas = this.MaxVizsgaKapacitas,
                IsTobbOraTarthato = this.IsTobbOraTarthato,
                IsWifiLefedett = this.IsWifiLefedett,
                IsInternetkapcsolatElerheto = this.IsInternetkapcsolatElerheto,
                MinOktCelraHasznaltSzamitogepekSzama = this.MinOktCelraHasznaltSzamitogepekSzama,
                MaxOktCelraHasznaltSzamitogepekSzama = this.MaxOktCelraHasznaltSzamitogepekSzama,
                IsInterakttablavalMunkaallomassalFelszerelt = this.IsInterakttablavalMunkaallomassalFelszerelt,
                SzervezetId = SzervezetId,
                IsFromSzervezet = IsFromSzervezet,
                SzervezetNev = SzervezetNev,
                SzervezetAzonosito = SzervezetAzonosito,
            };
        }
    }
}