using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web.Mvc; using Foolproof; using Kreta.BusinessLogic.Classes; using Kreta.BusinessLogic.HelperClasses; using Kreta.Enums; using Kreta.Enums.ManualEnums; using Kreta.Resources; using Kreta.Web.Helpers; using Kreta.Web.Helpers.TabStrip; using Kreta.Web.Models; using Kreta.Web.Security; namespace Kreta.Web.Areas.Tantargy.Models { public class TantargyModel { public TantargyModel() { TabList = new List(); RadioButtonItems = new List(); ErtekelesKorlatozasList = GetErtekelesKorlatozasList(); AmiKepzesiJellemzokModel = new AmiKepzesiJellemzokModel(); } public int? ID { get; set; } public List TabList { get; set; } public List RadioButtonItems { get; set; } public AmiKepzesiJellemzokModel AmiKepzesiJellemzokModel { get; set; } public List NemzetiDokumentumNyelvek { get; set; } = new List(); public bool NemzetiDokumentumNyelvekMegjelenjenek { get { return NemzetiDokumentumNyelvek.Any(x => x == ((int)AnyanyelvEnum.horvat) || x == ((int)AnyanyelvEnum.szerb) || x == ((int)AnyanyelvEnum.roman)); } } [Display(Name = nameof(TantargyResource.Tanev), ResourceType = typeof(TantargyResource))] public string Tanev { get; set; } [Display(Name = nameof(TantargyResource.TantargyNev), ResourceType = typeof(TantargyResource))] [Required(ErrorMessageResourceName = nameof(TantargyResource.ATantargyNevMegadasaKotelezo), ErrorMessageResourceType = typeof(TantargyResource))] [MaxLength(150, ErrorMessageResourceName = nameof(TantargyResource.ATantargyNeveMaximum150KarakterLehet), ErrorMessageResourceType = typeof(TantargyResource))] public string TantargyNev { get; set; } [Display(Name = nameof(TantargyResource.TantargyRovidnev), ResourceType = typeof(TantargyResource))] [MaxLength(20, ErrorMessageResourceName = nameof(TantargyResource.ATantargyRovidNevMaximum20KarakterLehet), ErrorMessageResourceType = typeof(TantargyResource))] public string TantargyRovidNev { get; set; } [Display(Name = nameof(TantargyResource.TantargyKategoria), ResourceType = typeof(TantargyResource))] [Required(ErrorMessageResourceName = nameof(TantargyResource.ATantargyKategoriaMegadasaKotelezo), ErrorMessageResourceType = typeof(TantargyResource))] public int? TargyKategoria { get; set; } [Display(Name = nameof(TantargyResource.TantargyKategoria), ResourceType = typeof(TantargyResource))] public string TargyKategoriaNev { get; set; } [Display(Name = nameof(TantargyResource.ESLTantargyKategoria), ResourceType = typeof(TantargyResource))] [Required(ErrorMessageResourceName = nameof(TantargyResource.AzESLTargyKategoriaMegadasaKotelezo), ErrorMessageResourceType = typeof(TantargyResource))] public int? ESLTargyKategoria { get; set; } [Display(Name = nameof(TantargyResource.ESLTantargyKategoria), ResourceType = typeof(TantargyResource))] public string ESLTargyKategoriaNev { get; set; } [Display(Name = nameof(TantargyResource.KapcsolodoFotantargyNeve), ResourceType = typeof(TantargyResource))] [RequiredIf(nameof(FoTargyIDValidationAttr), true, ErrorMessageResourceName = nameof(TantargyResource.KapcsolodoFotantargyNevenekMegadasaKotelezo), ErrorMessageResourceType = typeof(TantargyResource))] public int? FoTargyID { get; set; } public bool FoTargyIDValidationAttr => AltantargyNyomtatvanyban || !IsFoTargy; [Display(Name = nameof(TantargyResource.KapcsolodoFotantargyNeve), ResourceType = typeof(TantargyResource))] public string FoTargyNev { get; set; } [Display(Name = nameof(TantargyResource.Fotantargy), ResourceType = typeof(TantargyResource))] public bool IsFoTargy { get; set; } [Display(Name = nameof(TantargyResource.Fotantargy), ResourceType = typeof(TantargyResource))] public string IsFoTargy_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(IsFoTargy ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.KollegiumiTargy), ResourceType = typeof(TantargyResource))] public bool IsKollegiumiTargy { get; set; } [Display(Name = nameof(TantargyResource.KollegiumiTargy), ResourceType = typeof(TantargyResource))] public string IsKollegiumiTargy_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(IsKollegiumiTargy ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.GyakorlatiTargy), ResourceType = typeof(TantargyResource))] public bool GyakorlatiTargy { get; set; } [Display(Name = nameof(TantargyResource.GyakorlatiTargy), ResourceType = typeof(TantargyResource))] public string GyakorlatiTargy_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(GyakorlatiTargy ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.AmiTargy), ResourceType = typeof(TantargyResource))] public bool IsAmiTargyMod { get; set; } [Display(Name = nameof(TantargyResource.MSZGtantargy), ResourceType = typeof(TantargyResource))] public bool IsMszgTargy { get; set; } [Display(Name = nameof(TantargyResource.MSZGtantargy), ResourceType = typeof(TantargyResource))] public string IsMszgTargy_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(IsMszgTargy ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.AmiTargy), ResourceType = typeof(TantargyResource))] public string IsAmiTargy_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(IsAmiTargyMod ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.FelnottoktatasTargy), ResourceType = typeof(TantargyResource))] public bool IsFelnottOktatasTargy { get; set; } [Display(Name = nameof(TantargyResource.AltantargykentBizonyitvanyban), ResourceType = typeof(TantargyResource))] public bool AltantargyNyomtatvanyban { get; set; } [Display(Name = nameof(TantargyResource.AltantargykentBizonyitvanyban), ResourceType = typeof(TantargyResource))] public string AltantargyNyomtatvanyban_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(AltantargyNyomtatvanyban ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.FelnottoktatasTargy), ResourceType = typeof(TantargyResource))] public bool IsFelnottOktatas { get; set; } [Display(Name = nameof(TantargyResource.FelnottoktatasTargy), ResourceType = typeof(TantargyResource))] public string IsFelnottOktatas_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(IsFelnottOktatas ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.IsEgymi), ResourceType = typeof(TantargyResource))] public bool IsEgymi { get; set; } [Display(Name = nameof(TantargyResource.IsEgymi), ResourceType = typeof(TantargyResource))] public string IsEgymi_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(IsEgymi ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.TanulmanyiAtlagbaNemSzamitBele), ResourceType = typeof(TantargyResource))] public bool IsTanulmanyiAtlagbaNemSzamit { get; set; } [Display(Name = nameof(TantargyResource.TanulmanyiAtlagbaNemSzamitBele), ResourceType = typeof(TantargyResource))] public string IsTanulmanyiAtlagbaNemSzamit_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(IsTanulmanyiAtlagbaNemSzamit ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.NincsBeloleOra), ResourceType = typeof(TantargyResource))] public bool IsNincsBeloleOraMod { get; set; } [Display(Name = nameof(TantargyResource.NincsBeloleOra), ResourceType = typeof(TantargyResource))] public string IsNincsBeloleOra_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(IsNincsBeloleOraMod ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.OsztalynaplobanNemJelenikMeg), ResourceType = typeof(TantargyResource))] public bool IsOsztalynaplobanNemJelenikMeg { get; set; } [Display(Name = nameof(TantargyResource.OsztalynaplobanNemJelenikMeg), ResourceType = typeof(TantargyResource))] public string IsOsztalynaplobanNemJelenikMeg_BNAME { get { return IsOsztalynaplobanNemJelenikMeg ? IgenNemEnum.Igen.GetDisplayName(ClaimData.SelectedTanevID.Value) : IgenNemEnum.Nem.GetDisplayName(ClaimData.SelectedTanevID.Value); } } [Display(Name = nameof(TantargyResource.OsztalynaplobanMegjelenik), ResourceType = typeof(TantargyResource))] public bool IsOsztalyOrarendjebenMegjelenik { get; set; } [Display(Name = nameof(TantargyResource.OsztalynaplobanMegjelenik), ResourceType = typeof(TantargyResource))] public string IsOsztalyokOrarendjebenMegjelenik_BNAME { get { return Kreta.Framework.StringResourcesUtil.GetString(IsOsztalyOrarendjebenMegjelenik ? 133 : 134); } } //Igen, Nem [Display(Name = nameof(TantargyResource.OsztalyEsTanuloiOrarendbenNemJelenikMeg), ResourceType = typeof(TantargyResource))] public bool IsOsztalyEsTanuloiOrarendbenNemJelenikMeg { get => !IsOsztalyOrarendjebenMegjelenik; set => IsOsztalyOrarendjebenMegjelenik = !value; } [MaxLength(150, ErrorMessageResourceName = nameof(TantargyResource.ABizonyitvanybanMegjelenoNevMaximum150KarakterLehet), ErrorMessageResourceType = typeof(TantargyResource))] [Display(Name = nameof(TantargyResource.BizonyitvanybanMegjelenoNev), ResourceType = typeof(TantargyResource))] public string NevNyomtatvanyban { get; set; } [Display(Name = nameof(TantargyResource.AngolTantargyNev), ResourceType = typeof(TantargyResource))] [MaxLength(150, ErrorMessageResourceName = nameof(TantargyResource.ATantargyNeveMaximum150KarakterLehet), ErrorMessageResourceType = typeof(TantargyResource))] public string TantargyAngolNev { get; set; } [Display(Name = nameof(TantargyResource.NemetTantargyNev), ResourceType = typeof(TantargyResource))] [MaxLength(150, ErrorMessageResourceName = nameof(TantargyResource.ATantargyNeveMaximum150KarakterLehet), ErrorMessageResourceType = typeof(TantargyResource))] public string TantargyNemetNev { get; set; } [Display(Name = nameof(TantargyResource.HorvatTantargyNev), ResourceType = typeof(TantargyResource))] [MaxLength(150, ErrorMessageResourceName = nameof(TantargyResource.ATantargyNeveMaximum150KarakterLehet), ErrorMessageResourceType = typeof(TantargyResource))] public string TantargyHorvatNev { get; set; } [Display(Name = nameof(TantargyResource.RomanTantargyNev), ResourceType = typeof(TantargyResource))] [MaxLength(150, ErrorMessageResourceName = nameof(TantargyResource.ATantargyNeveMaximum150KarakterLehet), ErrorMessageResourceType = typeof(TantargyResource))] public string TantargyRomanNev { get; set; } [Display(Name = nameof(TantargyResource.SzerbTantargyNev), ResourceType = typeof(TantargyResource))] [MaxLength(150, ErrorMessageResourceName = nameof(TantargyResource.ATantargyNeveMaximum150KarakterLehet), ErrorMessageResourceType = typeof(TantargyResource))] public string TantargySzerbNev { get; set; } [Display(Name = nameof(TantargyResource.Sorszam), ResourceType = typeof(TantargyResource))] [Range(Core.Constants.MinMaxValues.MinTantargySorszam, Core.Constants.MinMaxValues.MaxTantargySorszam, ErrorMessageResourceName = nameof(ErrorResource.Ervenytelen), ErrorMessageResourceType = typeof(ErrorResource))] public int Sorszam { get; set; } [Display(Name = nameof(CommonResource.Megjegyzes), ResourceType = typeof(CommonResource))] [StringLength(500, ErrorMessageResourceName = nameof(CommonResource.AMegjegyzesSzovegeNemLehet500KarakternelHosszabb), ErrorMessageResourceType = typeof(ErrorResource))] public string Megjegyzes { get; set; } public List GyakorlatigenyessegKategoriak { get { return Kreta.Core.Constants.GyakorlatigenyessegTargyKategoriaTipusIdList; } } public bool IsGyakorlatigenyessegKategoria { get { return ClaimData.IsSelectedTanev20_21OrLater && ClaimData.IsSzakkepzoIntezmeny && TargyKategoria.HasValue && GyakorlatigenyessegKategoriak.Contains(TargyKategoria.Value); } } [RequiredIf(nameof(IsGyakorlatigenyessegKategoria), true, ErrorMessageResourceName = nameof(TantargyResource.GyakorlatigenyessegKitolteseKotelezo), ErrorMessageResourceType = typeof(TantargyResource))] [KretaRange(1, 99, ErrorMessageResourceName = nameof(TantargyResource.SzazalekosErtekNincsAMegengedettTartomanyban), ErrorMessageResourceType = typeof(TantargyResource))] [Display(Name = nameof(TantargyResource.Gyakorlatigenyesseg), ResourceType = typeof(TantargyResource))] public int? Gyakorlatigenyesseg { get; set; } [Display(Name = nameof(TantargyResource.ErtekelesKorlatozas), ResourceType = typeof(TantargyResource))] public List ErtekelesKorlatozasIdList { get; set; } [Display(Name = nameof(TantargyResource.ErtekelesKorlatozas), ResourceType = typeof(TantargyResource))] public string ErtekelesKorlatozasStringList { get { var result = new List(); foreach (var item in ErtekelesKorlatozasList) { if (int.TryParse(item.Value, out int id)) { if (ErtekelesKorlatozasIdList.Contains(id)) { result.Add(item.Text); } } } return string.Join(", ", result); } } public List ErtekelesKorlatozasList { get; set; } private List GetErtekelesKorlatozasList() { var dictionary = EnumExtensions.EnumToDictionary(ClaimData.SelectedTanevID.Value, false, true); return dictionary.ToSelectListItemList(); } public void SetDefaultsForNew() { TargyKategoria = (int)TargyKategoriaTipusEnum.na; IsFoTargy = true; Sorszam = Core.Constants.MinMaxValues.MinTantargySorszam; IsTanulmanyiAtlagbaNemSzamit = false; ErtekelesKorlatozasIdList = Enum.GetValues(typeof(ErtekelesKorlatozas)).Cast().Cast().ToList(); IsOsztalynaplobanNemJelenikMeg = false; IsOsztalyOrarendjebenMegjelenik = true; AmiKepzesiJellemzokModel.MufajTipusId = (int)MufajTipusEnum.na; AmiKepzesiJellemzokModel.TanszakTipusId = (int)TanszakTipusEnum.na; } public void SetErtekelesKorlatozasIdList(TantargyCO co) { ErtekelesKorlatozasIdList = new List(); if (co.IsOsztalyzattalErtekelheto) { ErtekelesKorlatozasIdList.Add((int)ErtekelesKorlatozas.OsztalyzattalErtekelheto); } if (co.IsSzovegesenErtekelheto) { ErtekelesKorlatozasIdList.Add((int)ErtekelesKorlatozas.SzovegesenErtekelheto); } if (co.IsSzazalekosanErtekelheto) { ErtekelesKorlatozasIdList.Add((int)ErtekelesKorlatozas.SzazalekosanErtekelheto); } } } }