using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Foolproof; using Kreta.BusinessLogic.Classes; using Kreta.BusinessLogic.HelperClasses; using Kreta.Core.CustomAttributes; using Kreta.Core.Domain; using Kreta.Enums; using Kreta.Resources; using Kreta.Web.Models.EditorTemplates; using Kreta.Web.Security; using static Kreta.Core.Constants; using static Kreta.Core.EntityInfos.EntityLengths; namespace Kreta.Web.Models { public class CimElerhetosegModel : PanelBarChildModel { public int? Id { get; set; } public int FelhasznaloId { get; set; } [RequiredIf("IsGondviseloJelszoIgenylo", true, ErrorMessageResourceName = nameof(ErrorResource.OktatasiAzonositoKitolteseKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [RegularExpression(RegularExpressions.OktatasiAzonositoTanulo, ErrorMessageResourceName = nameof(ErrorResource.OktatasiAzonositoFormatumaNemMegfeleloTanulo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(TanuloResource.OktatasiAzonosito), ResourceType = typeof(TanuloResource))] public string OktatasiAzonosito_JelszoIgenylo { get; set; } [RequiredIf("IsGondviseloJelszoIgenylo", true, ErrorMessageResourceName = nameof(ErrorResource.GondviseloNeveKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [StringLength(200, ErrorMessageResourceName = nameof(ErrorResource.GondviseloNeveMax200Karakter), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(TanuloResource.GondviseloNeve), ResourceType = typeof(TanuloResource))] public string GondviseloNev_JelszoIgenylo { get; set; } [RequiredIf("IsGondviseloJelszoIgenylo", true, ErrorMessageResourceName = nameof(ErrorResource.GondviseloRokonsagiFokaKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(TanuloResource.RokonsagiFok), ResourceType = typeof(TanuloResource))] public int? RokonsagiFok_JelszoIgenylo { get; set; } [RequiredIf("IsGondviseloElerhetoseg", true, ErrorMessageResourceName = nameof(ErrorResource.AGondviseloKivalasztasaKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(TanuloResource.GondviseloNeve), ResourceType = typeof(TanuloResource))] public int? GondviseloId { get; set; } [Required(ErrorMessageResourceName = nameof(ErrorResource.CimTipusMegadasaKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(CommonResource.CimTipusa), ResourceType = typeof(CommonResource))] public int? CimTipus { get; set; } = (int)CimTipusEnum.allando_lakcim; [Display(Name = nameof(TanuloResource.CimTipusa), ResourceType = typeof(TanuloResource))] public string CimTipusStr => TanuloResource.AllandoLakcim; [Display(Name = nameof(TanuloResource.CimTipusa), ResourceType = typeof(TanuloResource))] public string TartozkodasiCimTipusStr => TanuloResource.TartozkodasiHely; [RequiredIf("TanulovalEgyezik", false, ErrorMessageResourceName = nameof(ErrorResource.OrszagMegadasaKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(CommonResource.Orszag), ResourceType = typeof(CommonResource))] public int? Orszag { get; set; } [RequiredIf("KulfoldiCimValidationAttr", true, ErrorMessageResourceName = nameof(ErrorResource.IranyitoszamKitolteseKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [StringLength(20, ErrorMessageResourceName = nameof(AlkalmazottResource.IranyitoszamMax20Karakter), ErrorMessageResourceType = typeof(AlkalmazottResource))] [Display(Name = nameof(CommonResource.Iranyitoszam), ResourceType = typeof(CommonResource))] public string Iranyitoszam { get; set; } [RequiredIf("TanulovalEgyezik", false, ErrorMessageResourceName = nameof(ErrorResource.IranyitoszamKitolteseKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [StringLength(20, ErrorMessageResourceName = nameof(AlkalmazottResource.IranyitoszamMax20Karakter), ErrorMessageResourceType = typeof(AlkalmazottResource))] [Display(Name = nameof(CommonResource.Iranyitoszam), ResourceType = typeof(CommonResource))] public string Iranyitoszam_Str { get; set; } [RequiredIf("KulfoldiCimValidationAttr", true, ErrorMessageResourceName = nameof(ErrorResource.HelysegKitolteseKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [StringLength(200, ErrorMessageResourceName = nameof(AlkalmazottResource.HelysegMax200Karakter), ErrorMessageResourceType = typeof(AlkalmazottResource))] [Display(Name = nameof(CommonResource.Helyseg), ResourceType = typeof(CommonResource))] public string HelysegNev { get; set; } [RequiredIf("TanulovalEgyezik", false, ErrorMessageResourceName = nameof(ErrorResource.HelysegKitolteseKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [StringLength(200, ErrorMessageResourceName = nameof(AlkalmazottResource.HelysegMax200Karakter), ErrorMessageResourceType = typeof(AlkalmazottResource))] [Display(Name = nameof(CommonResource.Helyseg), ResourceType = typeof(CommonResource))] public string HelysegNev_Str { get; set; } [RequiredIf("TanulovalEgyezik", false, ErrorMessageResourceName = nameof(ErrorResource.KozteruletNevenekKitolteseKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [StringLength(40, ErrorMessageResourceName = nameof(AlkalmazottResource.KozteruletNeveMax40Karakter), ErrorMessageResourceType = typeof(AlkalmazottResource))] [Display(Name = nameof(CommonResource.KozteruletNev), ResourceType = typeof(CommonResource))] public string KozteruletNev { get; set; } [Display(Name = nameof(CommonResource.KozteruletJellege), ResourceType = typeof(CommonResource))] public string KozteruletTipus { get; set; } //Ez a KretaComboBox-hoz public bool KulfoldiCimValidationAttr { get { if (!TanulovalEgyezik) if (Orszag == (int)OrszagTipusEnum.Magyarorszag) return true; return false; } } public bool IsKozpontilagSzinkronizalt { get; set; } [RequiredIf("CimTanulovalEgyezikVagyMagyarorszagi", false, ErrorMessageResourceName = nameof(ErrorResource.KozteruletJellegenekKitolteseKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(CommonResource.KozteruletJellege), ResourceType = typeof(CommonResource))] public string KozteruletTipus_Str { get; set; } //Ez a KretaTextBox-hoz [RequiredIf("TanulovalEgyezik", false, ErrorMessageResourceName = nameof(ErrorResource.HazszamKitolteseKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [StringLength(Cim.HazszamLength, ErrorMessageResourceName = nameof(CommonResource.MaxLengthValidation), ErrorMessageResourceType = typeof(CommonResource))] [Display(Name = nameof(CommonResource.Hazszam), ResourceType = typeof(CommonResource))] public string Hazszam { get; set; } [StringLength(Cim.EmeletLength, ErrorMessageResourceName = nameof(CommonResource.MaxLengthValidation), ErrorMessageResourceType = typeof(CommonResource))] [Display(Name = nameof(CommonResource.Emelet), ResourceType = typeof(CommonResource))] public string Emelet { get; set; } [StringLength(Cim.AjtoLength, ErrorMessageResourceName = nameof(CommonResource.MaxLengthValidation), ErrorMessageResourceType = typeof(CommonResource))] [Display(Name = nameof(CommonResource.Ajto), ResourceType = typeof(CommonResource))] public string Ajto { get; set; } //Tartózkodásihely [Display(Name = nameof(CommonResource.Orszag), ResourceType = typeof(CommonResource))] public int? TartozkodasiOrszag { get; set; } [Display(Name = nameof(CommonResource.Iranyitoszam), ResourceType = typeof(CommonResource))] public string TartozkodasiIranyitoszam { get; set; } [Display(Name = nameof(CommonResource.Helyseg), ResourceType = typeof(CommonResource))] public string TartozkodasiHelysegNev { get; set; } [Display(Name = nameof(CommonResource.KozteruletNev), ResourceType = typeof(CommonResource))] public string TartozkodasiKozteruletNev { get; set; } [Display(Name = nameof(CommonResource.KozteruletJellege), ResourceType = typeof(CommonResource))] public string TartozkodasiKozteruletTipusNev { get; set; } [Display(Name = nameof(CommonResource.Hazszam), ResourceType = typeof(CommonResource))] public string TartozkodasiHazszam { get; set; } [Display(Name = nameof(CommonResource.Emelet), ResourceType = typeof(CommonResource))] public string TartozkodasiEmelet { get; set; } [Display(Name = nameof(CommonResource.Ajto), ResourceType = typeof(CommonResource))] public string TartozkodasiAjto { get; set; } public bool HasTartozkodasiHely { get; set; } [Display(Name = nameof(CommonResource.Alapertelmezett), ResourceType = typeof(CommonResource))] public bool AlapertelmezettCim { get; set; } [Display(Name = nameof(CommonResource.Alapertelmezett), ResourceType = typeof(CommonResource))] public bool AlapertelmezettEmail { get; set; } [Display(Name = nameof(CommonResource.Alapertelmezett), ResourceType = typeof(CommonResource))] public bool AlapertelmezettTel { get; set; } [Display(Name = nameof(TanuloResource.CimMegegyezikATanuloCimevel), ResourceType = typeof(TanuloResource))] public bool TanulovalEgyezik { get; set; } = false; public bool CimTanulovalEgyezikVagyMagyarorszagi => Orszag == (int)OrszagTipusEnum.Magyarorszag || TanulovalEgyezik; [RequiredIf("TelefonKotelezo", true, ErrorMessageResourceName = nameof(ErrorResource.TelefonszamMegadasaKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [PhoneExtended(ErrorMessageResourceName = nameof(ErrorResource.ATelefonszamFormatumaNemMegfelelo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(CommonResource.Telefonszam), ResourceType = typeof(CommonResource))] public string Telefon { get; set; } [RequiredIf("TelefonKotelezo", true, ErrorMessageResourceName = nameof(ErrorResource.TelefonTipusMegadasaKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(CommonResource.TelefonTipus), ResourceType = typeof(CommonResource))] public int? TelefonTipus { get; set; } [PhoneExtended(ErrorMessageResourceName = nameof(ErrorResource.ATelefonszamFormatumaNemMegfelelo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(CommonResource.Telefonszam2), ResourceType = typeof(CommonResource))] public string Telefon2 { get; set; } [Display(Name = nameof(CommonResource.TelefonTipus), ResourceType = typeof(CommonResource))] public int? TelefonTipus2 { get; set; } [RequiredIf("EmailcimKotelezo", true, ErrorMessageResourceName = nameof(ErrorResource.EmailCimMegadasaKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [StringLength(General.EmailMaximumKarakterekSzama, ErrorMessageResourceName = nameof(ErrorResource.EmailMax0Karakter), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(CommonResource.Email), ResourceType = typeof(CommonResource))] public string Emailcim_Input { get; set; } [EmailAddressExtended(ErrorMessageResourceName = nameof(ErrorResource.EMailCimFormatumaNemMegfelelo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(CommonResource.Email), ResourceType = typeof(CommonResource))] public string Emailcim => Emailcim_Input?.Trim(); [RequiredIf("EmailTipusKotelezo", true, ErrorMessageResourceName = nameof(ErrorResource.EmailTipusMegadasaKotelezo), ErrorMessageResourceType = typeof(ErrorResource))] [Display(Name = nameof(CommonResource.EmailTipus), ResourceType = typeof(CommonResource))] public int? EmailTipus { get; set; } public string EmailTipusStr => EmailTipus.GetDisplayName(ClaimData.SelectedTanevID.Value); public string TelefonTipusStr => TelefonTipus.GetDisplayName(ClaimData.SelectedTanevID.Value); public string TelefonTipus2Str => TelefonTipus2.GetDisplayName(ClaimData.SelectedTanevID.Value); public string OrszagStr => Orszag.GetDisplayName(ClaimData.SelectedTanevID.Value); public string TartozkodasiOrszagStr => TartozkodasiOrszag.GetDisplayName(ClaimData.SelectedTanevID.Value); [Display(Name = nameof(TanuloResource.TelefonElerhetosegek), ResourceType = typeof(TanuloResource))] public int? TanuloElerhetosegTelId { get; set; } [Display(Name = nameof(TanuloResource.EmailElerhetosegek), ResourceType = typeof(TanuloResource))] public int? TanuloElerhetosegEmailId { get; set; } public bool IsAutoBindNeeded { get; set; } = true; public List FormSettings { get; set; } = new List(); public bool IsAlapertelmezettVisible { get; set; } = true; public bool IsAlapertelmezettModosithato { get; set; } = true; public bool IsGondviseloElerhetoseg { get; set; } = false; public bool EmailcimKotelezo { get; set; } = false; public bool EmailTipusKotelezo { get; set; } = false; public bool TelefonKotelezo { get; set; } = false; public bool IsGondviseloJelszoIgenylo { get; set; } = false; public List GondviselokAlapertelmezettCimmel { get; set; } public string ComboBoxApiControllerName { get; set; } = Constants.ApiControllers.ComboBoxHelperApi; public static CimElerhetosegModel ConvertCoToModel(ElerhetosegCimCO co) { var model = new CimElerhetosegModel(); model.Id = co.ID; model.GondviseloId = co.GondviseloId; model.Iranyitoszam_Str = co.Iranyitoszam; model.Iranyitoszam = co.Iranyitoszam; model.HelysegNev = co.HelysegNev; model.HelysegNev_Str = co.HelysegNev; model.KozteruletNev = co.KozteruletNev; model.KozteruletTipus = co.KozteruletTipusNev; model.KozteruletTipus_Str = co.KozteruletTipusNev; model.Hazszam = co.Hazszam; model.Emelet = co.Emelet; model.Ajto = co.Ajto; model.CimTipus = co.CimTipus; model.Orszag = co.Orszag ?? (int)OrszagTipusEnum.Magyarorszag; model.FelhasznaloId = co.FelhasznaloId; model.AlapertelmezettCim = co.Alapertelmezett; return model; } public static CimElerhetosegModel ConvertCoToModel(TanuloAdatCO co) { var model = new CimElerhetosegModel(); model.Id = co.ID; model.Iranyitoszam_Str = co.Iranyitoszam; model.Iranyitoszam = co.Iranyitoszam; model.HelysegNev = co.HelysegNev; model.HelysegNev_Str = co.HelysegNev; model.KozteruletNev = co.KozteruletNev; model.KozteruletTipus_Str = co.KozteruletTipusNev; model.Hazszam = co.Hazszam; model.Emelet = co.Emelet; model.Ajto = co.Ajto; model.Orszag = co.Orszag ?? (int)OrszagTipusEnum.Magyarorszag; model.Emailcim_Input = co.Emailcim; model.EmailTipus = co.EmailTipusId; model.Telefon = co.Telefonszam; model.TelefonTipus = co.TelefonTipus; model.TartozkodasiOrszag = co.TartozkodasiOrszag; model.TartozkodasiIranyitoszam = co.TartozkodasiIranyitoszam; model.TartozkodasiHelysegNev = co.TartozkodasiHelysegNev; model.TartozkodasiKozteruletNev = co.TartozkodasiKozteruletNev; model.TartozkodasiKozteruletTipusNev = co.TartozkodasiKozteruletTipusNev; model.TartozkodasiHazszam = co.TartozkodasiHazszam; model.TartozkodasiEmelet = co.TartozkodasiEmelet; model.TartozkodasiAjto = co.TartozkodasiAjto; model.HasTartozkodasiHely = co.HasTartozkodasiHely; return model; } public static CimElerhetosegModel ConvertCoToModel(AlkalmazottElerhetosegCimCO co) { var model = new CimElerhetosegModel(); model.Id = co.ID; model.FelhasznaloId = co.AlkalmazottId; model.Iranyitoszam_Str = co.Iranyitoszam; model.Iranyitoszam = co.Iranyitoszam; model.HelysegNev_Str = co.HelysegNev; model.HelysegNev = co.HelysegNev; model.KozteruletNev = co.KozteruletNev; model.KozteruletTipus = co.KozteruletTipusNev; model.KozteruletTipus_Str = co.KozteruletTipusNev; model.Hazszam = co.Hazszam; model.Emelet = co.Emelet; model.Ajto = co.Ajto; model.AlapertelmezettCim = co.Alapertelmezett; model.CimTipus = co.CimTipus; model.Orszag = co.Orszag ?? (int)OrszagTipusEnum.Magyarorszag; return model; } public static CimElerhetosegModel ConvertCoToModel(AlkalmazottElerhetosegEmailCO co) { var model = new CimElerhetosegModel(); model.Id = co.ID; model.FelhasznaloId = co.AlkalmazottId; model.Emailcim_Input = co.EmailCim; model.AlapertelmezettEmail = co.Alapertelmezett; model.EmailTipus = co.EmailTipusa; return model; } public static CimElerhetosegModel ConvertCoToModel(AlkalmazottElerhetosegTelCO co) { var model = new CimElerhetosegModel(); model.Id = co.ID; model.FelhasznaloId = co.AlkalmazottId; model.Telefon = co.Telefonszam; model.AlapertelmezettTel = co.Alapertelmezett; model.TelefonTipus = co.TelefonTipusa; return model; } public static CimElerhetosegModel ConvertCoToModel(TanuloElerhetosegTelCO co) { var model = new CimElerhetosegModel(); model.Id = co.ID; model.FelhasznaloId = co.TanuloId; model.Telefon = co.Telefonszam; model.AlapertelmezettTel = co.Alapertelmezett; model.TelefonTipus = co.TelefonTipusa; return model; } public static ElerhetosegCimCO ConvertModelToElerhetosegCimCO(CimElerhetosegModel model) { var co = new ElerhetosegCimCO(); co.ID = model.Id; co.GondviseloId = model.GondviseloId; co.FelhasznaloId = model.FelhasznaloId; co.Orszag = model.Orszag ?? (int)OrszagTipusEnum.Magyarorszag; co.Iranyitoszam = co.Orszag == (int)OrszagTipusEnum.Magyarorszag ? model.Iranyitoszam : model.Iranyitoszam_Str; co.HelysegNev = co.Orszag == (int)OrszagTipusEnum.Magyarorszag ? model.HelysegNev : model.HelysegNev_Str; co.KozteruletTipusNev = co.Orszag == (int)OrszagTipusEnum.Magyarorszag ? model.KozteruletTipus : model.KozteruletTipus_Str; co.KozteruletNev = model.KozteruletNev; co.Hazszam = model.Hazszam; co.Emelet = model.Emelet; co.Ajto = model.Ajto; co.CimTipus = model.CimTipus; co.Alapertelmezett = model.AlapertelmezettCim; co.tanuloval_egyezik = model.TanulovalEgyezik; return co; } public static FelhasznaloElerhetosegCimCO ConvertModelToFelhasznaloElerhetosegCo(CimElerhetosegModel model) { FelhasznaloElerhetosegCimCO co = new FelhasznaloElerhetosegCimCO(); co.ID = model.Id; co.Orszag = model.Orszag ?? (int)OrszagTipusEnum.Magyarorszag; co.Iranyitoszam = model.Iranyitoszam_Str; co.HelysegNev = model.HelysegNev_Str; co.KozteruletNev = model.KozteruletNev; co.KozteruletTipusNev = model.KozteruletTipus_Str; co.FelhasznaloId = model.FelhasznaloId; co.Hazszam = model.Hazszam; co.Emelet = model.Emelet; co.Ajto = model.Ajto; co.Alapertelmezett = model.AlapertelmezettCim; co.CimTipus = model.CimTipus ?? default(int); return co; } public static FelhasznaloElerhetosegEmailCO ConvertModelToFelhasznaloElerhetosegEmailCo(CimElerhetosegModel model) { var co = new FelhasznaloElerhetosegEmailCO(); co.ID = model.Id; co.FelhasznaloId = model.FelhasznaloId; co.EmailCim = model.Emailcim; co.Alapertelmezett = model.AlapertelmezettEmail; co.EmailTipusa = model.EmailTipus ?? default(int); return co; } public static FelhasznaloElerhetosegTelCO ConvertModelToFelhasznaloElerhetosegTelCo(CimElerhetosegModel model) { var co = new FelhasznaloElerhetosegTelCO(); co.ID = model.Id; co.FelhasznaloId = model.FelhasznaloId; co.Telefonszam = model.Telefon; co.Alapertelmezett = model.AlapertelmezettTel; co.TelefonTipusa = model.TelefonTipus ?? default(int); return co; } public static TanuloElerhetosegTelCO ConvertModelToTanuloElerhetosegTelCO(CimElerhetosegModel model) { var co = new TanuloElerhetosegTelCO(); co.ID = model.Id; co.TanuloId = model.FelhasznaloId; co.Telefonszam = model.Telefon; co.Alapertelmezett = model.AlapertelmezettTel; co.TelefonTipusa = model.TelefonTipus ?? default(int); return co; } public static TanuloElerhetosegEmailCO ConvertModelToTanuloElerhetosegEmailCO(CimElerhetosegModel model) { var co = new TanuloElerhetosegEmailCO(); co.ID = model.Id; co.TanuloId = model.FelhasznaloId; co.EmailCim = model.Emailcim; co.Alapertelmezett = model.AlapertelmezettEmail; co.EmailTipusa = model.EmailTipus ?? default(int); return co; } public static CimElerhetosegModel ConvertCoToModel(TanuloElerhetosegEmailCO co) { var model = new CimElerhetosegModel(); model.Id = co.ID; model.FelhasznaloId = co.TanuloId; model.Emailcim_Input = co.EmailCim; model.AlapertelmezettEmail = co.Alapertelmezett; model.EmailTipus = co.EmailTipusa; return model; } } public class CimElerhetosegConstant { public const string CimSectionVisible = "CimSectionVisible"; public const string EmailSectionVisible = "EmailSectionVisible"; public const string TelSectionVisible = "TelSectionVisible"; public const string VisibleTelefon2 = "VisibleTelefon2"; public const string AlapertelmezettNemModosithato = "AlapertelmezettNemModosithato"; public const string AlapertelmezettCimVisible = "AlapertelmezettCimVisible"; public const string AlapertelmezettEmailVisible = "AlapertelmezettEmailVisible"; public const string AlapertelmezettTelVisible = "AlapertelmezettTelVisible"; public const string IsNew = "IsNew"; public const string TanuloElerhetosegTelVisible = "TanuloElerhetosegTelVisible"; public const string TanuloElerhetosegEmailVisible = "TanuloElerhetosegEmailVisible"; public const string Nameof_TanulovalEgyezik = nameof(CimElerhetosegModel.TanulovalEgyezik); public const string Nameof_Orszag = nameof(CimElerhetosegModel.Orszag); public const string Nameof_Iranyitoszam = nameof(CimElerhetosegModel.Iranyitoszam); public const string Nameof_HelysegNev = nameof(CimElerhetosegModel.HelysegNev); public const string Nameof_KozteruletTipus = nameof(CimElerhetosegModel.KozteruletTipus); public const string SeparatorRowHide = "SeparatorRowHide"; public const string TartozkodasiHelyCimTipus = "TartozkodasiHelyCimTipus"; public const string AllandoLakcimCimTipus = nameof(AllandoLakcimCimTipus); public const string CsakMagyarorszag = "CsakMagyarorszag"; public const string TelepulesNev = "TelepulesNev"; } }