676 lines
29 KiB
C#
676 lines
29 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
using System.Web.Http.ModelBinding;
|
|
using Kendo.Mvc.UI;
|
|
using Kreta.BusinessLogic.HelperClasses;
|
|
using Kreta.BusinessLogic.Helpers;
|
|
using Kreta.BusinessLogic.Security;
|
|
using Kreta.Client.KGR;
|
|
using Kreta.Client.KGR.Request;
|
|
using Kreta.Core;
|
|
using Kreta.Core.FeatureToggle;
|
|
using Kreta.Core.Logic;
|
|
using Kreta.Framework;
|
|
using Kreta.Framework.Security;
|
|
using Kreta.Resources;
|
|
using Kreta.Web.Areas.Adminisztracio.Models;
|
|
using Kreta.Web.Helpers;
|
|
using Kreta.Web.Helpers.Error;
|
|
using Kreta.Web.Helpers.Grid;
|
|
using Kreta.Web.Models;
|
|
using Kreta.Web.Security;
|
|
using Kreta.Web.Utils;
|
|
using Newtonsoft.Json;
|
|
using static Kreta.Core.Constants;
|
|
|
|
namespace Kreta.Web.Areas.Adminisztracio.ApiControllers
|
|
{
|
|
[ApiRoleClaimsAuthorize(true)]
|
|
[MvcRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue, KretaClaimPackages.Naplo.ClaimValue, KretaClaimPackages.Ellenorzo.ClaimValue)]
|
|
public class ProfilApiController : ApiController
|
|
{
|
|
private readonly IKGRClient _kgrClient;
|
|
public ProfilApiController(IKGRClient kgrClient)
|
|
{
|
|
_kgrClient = kgrClient ?? throw new ArgumentNullException(nameof(kgrClient));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Jelszó módosítás mentés
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage SaveProfilData(ProfilModel model)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
try
|
|
{
|
|
var belepesiNev = ClaimData.BelepesiNev;
|
|
|
|
var helper = new FelhasznaloBelepesHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
|
|
|
var loginInfo = helper.AuthenticateUser(belepesiNev, model.JelenlegiJelszo);
|
|
|
|
if (loginInfo == null || loginInfo.PasswordState == PasswordState.INVALID)
|
|
{
|
|
throw new IncorrectPasswordException(loginInfo.BelepesiNev);
|
|
}
|
|
|
|
helper.ChangeUserPassword(belepesiNev, model.UjJelszo);
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
catch (IncorrectPasswordException)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, StringResourcesUtil.GetString(2591)/*Helytelen jelenlegi jelszó!*/);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new StatusError(HttpStatusCode.InternalServerError, StringResourcesUtil.GetString(439) /*Nem sikerült a művelet!*/)
|
|
{
|
|
UnHandledException = ex
|
|
};
|
|
}
|
|
}
|
|
|
|
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elérhetőség módosítás mentés
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage SaveElerhetosegek(ElerhetosegekModel model)
|
|
{
|
|
model.CleanFromEmptyRows();
|
|
if (!ValidateElerhetosegek(model, out var errorDictionary))
|
|
{
|
|
ModelState.AddRange(errorDictionary);
|
|
}
|
|
|
|
if (ModelState.IsValid)
|
|
{
|
|
try
|
|
{
|
|
var felhasznaloHelper = new FelhasznaloHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
var co = model.ConvertToCo();
|
|
var newDbElerhetosegek = felhasznaloHelper.SaveElerhetosegek(co, ClaimData.FelhasznaloId);
|
|
|
|
return Request.CreateResponse(HttpStatusCode.OK, newDbElerhetosegek);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new StatusError(HttpStatusCode.InternalServerError, ErrorResource.NemSikerultAMuvelet)
|
|
{
|
|
UnHandledException = ex
|
|
};
|
|
}
|
|
}
|
|
|
|
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Profilkép mentés
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage SaveProfilePicture()
|
|
{
|
|
if (!Request.Content.IsMimeMultipartContent())
|
|
{
|
|
throw new StatusError(HttpStatusCode.UnsupportedMediaType, StringResourcesUtil.GetString(4890)/*Nem támogatott tipus*/);
|
|
}
|
|
|
|
var root = HttpContext.Current.Server.MapPath("~/App_Data");
|
|
var provider = new MultipartFormDataStreamProvider(root);
|
|
|
|
var tempFilePath = provider.FileData[0].LocalFileName;
|
|
|
|
var byteArray = File.ReadAllBytes(tempFilePath);
|
|
|
|
var helper = new FelhasznaloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
|
|
|
ProfileUtils.UserProfileImage = helper.ProfileKep(helper.ProfilkepMentese(byteArray));
|
|
|
|
File.Delete(tempFilePath);
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage SaveGondviseloAdatok(GondviseloAdatokModModel model)
|
|
{
|
|
try
|
|
{
|
|
new TanuloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).SaveGondviseloElerhetosegAdatok(ConvertGondviseloAdatokModModelToCO(model));
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.NemSikerultAMuvelet) { UnHandledException = ex };
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage SaveGondviselo4TAdatok(Felhasznalo4TAdatokModel model)
|
|
{
|
|
if (!ClaimData.FeltarGondviseloEnabled)
|
|
{
|
|
throw new StatusError(HttpStatusCode.Forbidden, ErrorResource.NincsJogaAMuveletVegrehajtasahoz);
|
|
}
|
|
|
|
try
|
|
{
|
|
new GondviseloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).SaveGondviselo4TAdatok(ClaimData.GondviseloId.Value, ConvertGondviselo4TAdatokModelToCo(model));
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.NemSikerultAMuvelet) { UnHandledException = ex };
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public HttpResponseMessage DeleteGondviseloEmail()
|
|
{
|
|
try
|
|
{
|
|
new TanuloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).DeleteGondviseloEmail(ClaimData.GondviseloId.Value);
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.NemSikerultAMuvelet) { UnHandledException = ex };
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage SaveTanuloBankszamlaAdatok(TanuloBankszamlaModel model) => SaveBankszamlaAdatok(model, true);
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage SaveAlkalmazottBankszamlaAdatok(AlkalmazottBankszamlaModel model) => SaveBankszamlaAdatok(model, false);
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage SaveMentoriNyugdijAdatok(MentoriNyugdijModel model)
|
|
{
|
|
|
|
if (ModelState.IsValid)
|
|
{
|
|
try
|
|
{
|
|
var co = model.ConvertToCo();
|
|
var featureContext = (IFeatureContext)Request.GetDependencyScope().GetService(typeof(IFeatureContext));
|
|
var isKlebelsbergKozpontOrNSZFH =
|
|
featureContext.IsEnabled(FeatureName.MunkaugyiAdatokKlebelsberg)
|
|
|| featureContext.IsEnabled(FeatureName.MunkaugyiAdatokNSZFH);
|
|
var isNszfhUjSzkt = ClaimData.IsSelectedTanev20_21OrLater && ClaimData.IsSzakkepzoIntezmeny;
|
|
new AlkalmazottHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).SaveAlkalmazottNyugdijAdatok(co, isKlebelsbergKozpontOrNSZFH, isNszfhUjSzkt);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.NemSikerultAMuvelet) { UnHandledException = ex };
|
|
}
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
var errorMessage = string.Join("<br>", ModelState.Select(x => string.Join("<br>", x.Value.Errors.Select(y => y.ErrorMessage))));
|
|
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage);
|
|
}
|
|
|
|
[NonAction]
|
|
public HttpResponseMessage SaveBankszamlaAdatok(TanuloBankszamlaModel model, bool isTanulo)
|
|
{
|
|
var co = model.ConvertToCo();
|
|
if (!ValidateBankszamlaszamAdatok(co, out var errorDictionary))
|
|
{
|
|
ModelState.AddRange(errorDictionary);
|
|
}
|
|
|
|
if (ModelState.IsValid)
|
|
{
|
|
try
|
|
{
|
|
if (isTanulo)
|
|
{
|
|
new TanuloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).SaveTanuloBankszamlaAdatok(ClaimData.FelhasznaloId, ClaimData.GondviseloId, co);
|
|
}
|
|
else
|
|
{
|
|
new AlkalmazottHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).SaveAlkalmazottBankszamlaAdatok(ClaimData.FelhasznaloId, co);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.NemSikerultAMuvelet) { UnHandledException = ex };
|
|
}
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
var errorMessage = string.Join("<br>", ModelState.Select(x => string.Join("<br>", x.Value.Errors.Select(y => y.ErrorMessage))));
|
|
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage);
|
|
}
|
|
|
|
[ApiRolePackageAuthorize(KretaClaimPackages.Ellenorzo.ClaimValue)]
|
|
public DataSourceResult GetTanuloAdatGrid([ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
|
{
|
|
var helper = new FelhasznaloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
|
helper.GridParameters = Converter.GridParameter(request);
|
|
|
|
var ds = helper.GetTanuloAdatForGondviselo(ClaimData.GondviseloId.Value);
|
|
|
|
return ds.ToDataSourceResult();
|
|
}
|
|
|
|
[ApiRolePackageAuthorize(KretaClaimPackages.Naplo.ClaimValue, KretaClaimPackages.Ellenorzo.ClaimValue)]
|
|
public DataSourceResult GetElerhetosegCimGrid([ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
|
{
|
|
var helper = new FelhasznaloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
|
helper.GridParameters = Converter.GridParameter(request);
|
|
DataSet ds;
|
|
if (ClaimData.GondviseloId.HasValue)
|
|
{
|
|
ds = helper.GetCimData(ClaimData.GondviseloId.Value, isGondviselo: true);
|
|
}
|
|
else
|
|
{
|
|
ds = helper.GetCimData(ClaimData.FelhasznaloId, isGondviselo: false);
|
|
}
|
|
|
|
return ds.ToDataSourceResult();
|
|
}
|
|
|
|
[ApiRolePackageAuthorize(KretaClaimPackages.Naplo.ClaimValue, KretaClaimPackages.Ellenorzo.ClaimValue)]
|
|
public DataSourceResult GetElerhetosegTelGrid([ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
|
{
|
|
var helper = new FelhasznaloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
|
helper.GridParameters = Converter.GridParameter(request);
|
|
DataSet ds;
|
|
if (ClaimData.GondviseloId.HasValue)
|
|
{
|
|
ds = helper.GetTelefonData(ClaimData.GondviseloId.Value);
|
|
}
|
|
else
|
|
{
|
|
ds = helper.GetTelefonData(ClaimData.FelhasznaloId);
|
|
}
|
|
|
|
return ds.ToDataSourceResult();
|
|
}
|
|
|
|
[ApiRolePackageAuthorize(KretaClaimPackages.Naplo.ClaimValue, KretaClaimPackages.Ellenorzo.ClaimValue)]
|
|
public DataSourceResult GetElerhetosegEmailGrid([ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
|
{
|
|
var helper = new FelhasznaloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
|
helper.GridParameters = Converter.GridParameter(request);
|
|
DataSet ds;
|
|
if (ClaimData.GondviseloId.HasValue)
|
|
{
|
|
ds = helper.GetEmailData(ClaimData.GondviseloId.Value);
|
|
}
|
|
else
|
|
{
|
|
ds = helper.GetEmailData(ClaimData.FelhasznaloId);
|
|
}
|
|
|
|
return ds.ToDataSourceResult();
|
|
}
|
|
|
|
[ApiRolePackageAuthorize(KretaClaimPackages.Naplo.ClaimValue)]
|
|
public DataSourceResult GetTargyiEszkozokGrid([ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
|
{
|
|
var adatlapModels = new List<SajatAdatlapInfoModel.TargyiEszkozModel>();
|
|
|
|
try
|
|
{
|
|
var helper = new TanarHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
|
var tanaradatok = helper.GetTanarAdatok(ClaimData.FelhasznaloId);
|
|
|
|
string funkcioTerulet = null;
|
|
if (tanaradatok.FeladatellatasiHely.IsEntityId())
|
|
{
|
|
var mukodesiHelyId = new FeladatEllatasiHelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).GetFeladatEllatasiHelyAdatok(tanaradatok.FeladatellatasiHely.Value).MukodesiHelyID;
|
|
var co = new MukodesiHelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).GetMukodesiHelyAdatok(mukodesiHelyId);
|
|
funkcioTerulet = co.Funkcioterulet;
|
|
}
|
|
|
|
var alkalmazottHelper = new AlkalmazottHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
|
if (!string.IsNullOrWhiteSpace(alkalmazottHelper.GetAlkalmazottSztszKod(ClaimData.FelhasznaloId)))
|
|
{
|
|
var result = _kgrClient.KGREszkozList(new EszkozHeaderRequest() { IntezmenyGuid = ClaimData.IntezmenyGuid.ToString(), IntezmenyAzonosito = ClaimData.IntezmenyAzonosito, Sztsz = alkalmazottHelper.GetAlkalmazottSztszKod(ClaimData.FelhasznaloId) });
|
|
var cnt = 0;
|
|
foreach (var item in result)
|
|
{
|
|
adatlapModels.Add(new SajatAdatlapInfoModel.TargyiEszkozModel
|
|
{
|
|
ID = cnt.ToString(),
|
|
Megnevezes = item.Megnevezes,
|
|
GyariSzam = item.GyariSzam,
|
|
LeltariSzam = item.Leltarszam
|
|
});
|
|
cnt++;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SDAServer.Instance.Logger.ExceptionThrown(ex);
|
|
}
|
|
|
|
return adatlapModels.ToDataSourceResult();
|
|
}
|
|
|
|
private GondviseloAdatokModCO ConvertGondviseloAdatokModModelToCO(GondviseloAdatokModModel model)
|
|
{
|
|
return new GondviseloAdatokModCO
|
|
{
|
|
GondviseloId = ClaimData.GondviseloId.Value,
|
|
TanuloId = ClaimData.FelhasznaloId,
|
|
UjEmail = model.UjEmail,
|
|
UjTelefon = model.UjTelefon
|
|
};
|
|
}
|
|
|
|
private Felhasznalo4TAdatokCo ConvertGondviselo4TAdatokModelToCo(Felhasznalo4TAdatokModel model)
|
|
{
|
|
return new Felhasznalo4TAdatokCo
|
|
{
|
|
AnyjaUtonev = model.AnyjaUtonev,
|
|
AnyjaVezeteknev = model.AnyjaVezeteknev,
|
|
Elotag = model.Elotag,
|
|
SzuletesiDatum = model.SzuletesiDatum,
|
|
SzuletesiHely = model.SzuletesiHely,
|
|
SzuletesiUtonev = model.SzuletesiUtonev,
|
|
SzuletesiVezeteknev = model.SzuletesiVezeteknev,
|
|
Utonev = model.Utonev,
|
|
Vezeteknev = model.Vezeteknev,
|
|
};
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage SaveEgyHaztartasbanElokData(EgyhaztartasbanElokModel model)
|
|
{
|
|
if (!ValidateEgyHaztartasbanElok(model, out var errorDictionary))
|
|
{
|
|
ModelState.AddRange(errorDictionary);
|
|
}
|
|
|
|
if (ModelState.IsValid)
|
|
{
|
|
var helper = new FelhasznaloHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
helper.SaveEgyhaztartasbanElokData(model.ConvertToCo(), ClaimData.FelhasznaloId, ClaimData.GondviseloId);
|
|
|
|
return Request.CreateResponse(HttpStatusCode.OK);
|
|
}
|
|
|
|
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public string LoadEgyHaztartasbanElokData()
|
|
{
|
|
return JsonConvert.SerializeObject(new FelhasznaloHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetEgyhaztartasbanElokData(ClaimData.FelhasznaloId));
|
|
}
|
|
|
|
#region Helpers
|
|
|
|
private bool ValidateElerhetosegek(ElerhetosegekModel model, out Dictionary<string, List<string>> errorDictionary)
|
|
{
|
|
errorDictionary = new Dictionary<string, List<string>>();
|
|
|
|
if (model.Email.Where(e => e.Alapertelmezett && e.Status != Enums.ManualEnums.ElerhetosegStatusEnum.Deleted).Take(2).Count() != 1)
|
|
{
|
|
AddErrorMessage(errorDictionary, "Error", AdminisztracioResource.KotelezoEgyAlapertelmezettEmail);
|
|
}
|
|
|
|
if (model.Telefon.Where(t => t.Alapertelmezett && t.Status != Enums.ManualEnums.ElerhetosegStatusEnum.Deleted).Take(2).Count() != 1)
|
|
{
|
|
AddErrorMessage(errorDictionary, "Error", AdminisztracioResource.KotelezoEgyAlapertelmezettTelefon);
|
|
}
|
|
|
|
var publikusEmailCimek = model.Email.Where(e => e.IsPublic && e.Status != Enums.ManualEnums.ElerhetosegStatusEnum.Deleted);
|
|
if (publikusEmailCimek.Skip(1).Any())
|
|
{
|
|
foreach (var publikusEmail in publikusEmailCimek.Skip(1))
|
|
{
|
|
AddErrorMessage(errorDictionary, publikusEmail.TextBoxId, AdminisztracioResource.PublikusEmailCsakEgyLehet);
|
|
}
|
|
}
|
|
|
|
var publikusTelefonszamok = model.Telefon.Where(t => t.IsPublic && t.Status != Enums.ManualEnums.ElerhetosegStatusEnum.Deleted);
|
|
if (publikusTelefonszamok.Skip(1).Any())
|
|
{
|
|
foreach (var publikusTelefonszam in publikusTelefonszamok.Skip(1))
|
|
{
|
|
AddErrorMessage(errorDictionary, publikusTelefonszam.TextBoxId, AdminisztracioResource.PublikusTelefonCsakEgyLehet);
|
|
}
|
|
}
|
|
|
|
foreach (var email in model.Email.Where(e => e.Status != Enums.ManualEnums.ElerhetosegStatusEnum.Deleted))
|
|
{
|
|
if (!email.Tipus.HasValue)
|
|
{
|
|
AddErrorMessage(errorDictionary, email.ComboBoxId, AdminisztracioResource.EmailTipusKotelezo);
|
|
}
|
|
|
|
if (email.IsPublic && email.Alapertelmezett)
|
|
{
|
|
AddErrorMessage(errorDictionary, email.TextBoxId, AdminisztracioResource.PublikusEmailNemLehetAlapertelmezett);
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(email.EmailCim) || !email.EmailCim.IsValidEmail())
|
|
{
|
|
AddErrorMessage(errorDictionary, email.TextBoxId, ErrorResource.EMailCimFormatumaNemMegfelelo);
|
|
}
|
|
else
|
|
{
|
|
if (email.EmailCim.Length > General.EmailMaximumKarakterekSzama)
|
|
{
|
|
AddErrorMessage(errorDictionary, email.TextBoxId, ErrorResource.EmailMax0Karakter);
|
|
}
|
|
}
|
|
}
|
|
|
|
var nemToroltEmailek = model.Email.Where(x => x.Status != Enums.ManualEnums.ElerhetosegStatusEnum.Deleted).Select(x => x.EmailCim_Input).ToList();
|
|
if (nemToroltEmailek.Distinct().Count() != nemToroltEmailek.Count())
|
|
{
|
|
AddErrorMessage(errorDictionary, "Error", ErrorResource.AMegadottEmailcimMarRogzitveVan);
|
|
}
|
|
var nemToroltTelefonszamok = model.Telefon.Where(x => x.Status != Enums.ManualEnums.ElerhetosegStatusEnum.Deleted).Select(x => x.Telefonszam).ToList();
|
|
if (nemToroltTelefonszamok.Distinct().Count() != nemToroltTelefonszamok.Count())
|
|
{
|
|
AddErrorMessage(errorDictionary, "Error", ErrorResource.AMegadottTelefonszamMarRogzitveVan);
|
|
}
|
|
|
|
foreach (var telefon in model.Telefon.Where(t => t.Status != Enums.ManualEnums.ElerhetosegStatusEnum.Deleted))
|
|
{
|
|
if (!telefon.Tipus.HasValue)
|
|
{
|
|
AddErrorMessage(errorDictionary, telefon.ComboBoxId, AdminisztracioResource.TelefonTipusKotelezo);
|
|
}
|
|
|
|
if (telefon.IsPublic && telefon.Alapertelmezett)
|
|
{
|
|
AddErrorMessage(errorDictionary, telefon.TextBoxId, AdminisztracioResource.PublikusTelefonNemLehetAlapertelmezett);
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(telefon.Telefonszam) || !telefon.Telefonszam.IsValidPhone())
|
|
{
|
|
AddErrorMessage(errorDictionary, telefon.TextBoxId, ErrorResource.ATelefonszamFormatumaNemMegfelelo);
|
|
}
|
|
}
|
|
|
|
return !errorDictionary.Any();
|
|
}
|
|
|
|
private bool ValidateBankszamlaszamAdatok(BankszamlaCo model, out Dictionary<string, List<string>> errorDictionary)
|
|
{
|
|
errorDictionary = new Dictionary<string, List<string>>();
|
|
|
|
var errorText = BankszamlaLogic.KitoltottsegValidacio(model.BankszamlaSzam, model.BankszamlaTulajdonos, model.BankszamlaTulajdonosNeve);
|
|
|
|
if (!string.IsNullOrWhiteSpace(errorText))
|
|
{
|
|
AddErrorMessage(errorDictionary, nameof(model.BankszamlaSzam), errorText);
|
|
}
|
|
else
|
|
{
|
|
// NOTE: Üres a bankszámlaszám = törölni akarjuk a meglevő adatokat
|
|
if (string.IsNullOrWhiteSpace(model.BankszamlaSzam))
|
|
{
|
|
return true;
|
|
}
|
|
errorText = BankszamlaLogic.CDVValidacio(model.BankszamlaSzam);
|
|
|
|
if (!string.IsNullOrWhiteSpace(errorText))
|
|
{
|
|
AddErrorMessage(errorDictionary, nameof(model.BankszamlaSzam), errorText);
|
|
}
|
|
}
|
|
|
|
return !errorDictionary.Any();
|
|
}
|
|
|
|
private void AddErrorMessage(Dictionary<string, List<string>> errorDictionary, string key, string message)
|
|
{
|
|
if (!errorDictionary.TryGetValue(key, out var messages))
|
|
{
|
|
messages = new List<string>();
|
|
errorDictionary.Add(key, messages);
|
|
}
|
|
messages.Add(message);
|
|
}
|
|
|
|
private bool ValidateEgyHaztartasbanElok(EgyhaztartasbanElokModel model, out Dictionary<string, List<string>> errorDictionary)
|
|
{
|
|
errorDictionary = new Dictionary<string, List<string>>();
|
|
|
|
foreach (var item in model.Sorok.Where(t => !t.isDeleted))
|
|
{
|
|
if (string.IsNullOrWhiteSpace(item.Nev))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Nev_{item.RowNumber}", string.Format(FelhasznalokResource.NevKotelezo, item.RowNumber));
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(item.AnyjaNev))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"AnyjaNev_{item.RowNumber}", string.Format(FelhasznalokResource.AnyjaNeveKotelezo, item.RowNumber));
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(item.SzuletesiHely))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"SzuletesiHely_{item.RowNumber}", string.Format(FelhasznalokResource.SzuletesiHelyKotelezo, item.RowNumber));
|
|
}
|
|
|
|
if (!item.SzuletesiIdo.HasValue)
|
|
{
|
|
AddErrorMessage(errorDictionary, $"SzuletesiIdo_{item.RowNumber}", string.Format(FelhasznalokResource.SzuletesiIdoKotelezo, item.RowNumber));
|
|
}
|
|
|
|
if (item.SzuletesiIdo.HasValue && (item.SzuletesiIdo < DateTime.Today.AddYears(-150) || item.SzuletesiIdo > DateTime.Today))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"SzuletesiIdo_{item.RowNumber}", string.Format(FelhasznalokResource.SzuletesiIdoNemValid, item.RowNumber));
|
|
}
|
|
|
|
if (!item.RokonsagiFok.HasValue)
|
|
{
|
|
AddErrorMessage(errorDictionary, $"RokonsagiFok_{item.RowNumber}", string.Format(FelhasznalokResource.RokonsagiFokKotelezo, item.RowNumber));
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(item.Taj))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Taj_{item.RowNumber}", string.Format(FelhasznalokResource.TAJszamKotelezo, item.RowNumber));
|
|
}
|
|
else
|
|
{
|
|
if (item.Taj.Length != 9)
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Taj_{item.RowNumber}", string.Format(FelhasznalokResource.TAJszam9Karakter, item.RowNumber));
|
|
}
|
|
else if (string.Equals(item.Taj, "000000000", StringComparison.Ordinal))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Taj_{item.RowNumber}", string.Format(FelhasznalokResource.TAJszamCsupaNulla, item.RowNumber));
|
|
}
|
|
else
|
|
{
|
|
var tajszam = new int[9];
|
|
for (var x = 0; x < tajszam.Length; x++)
|
|
{
|
|
tajszam[x] = Convert.ToInt32(item.Taj.Substring(x, 1));
|
|
}
|
|
|
|
if ((((tajszam[1] + tajszam[3] + tajszam[5] + tajszam[7]) * 7) + ((tajszam[0] + tajszam[2] + tajszam[4] + tajszam[6]) * 3)) % 10 != tajszam[8])
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Taj_{item.RowNumber}", string.Format(FelhasznalokResource.TAJszamNemErvenyes, item.RowNumber));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(item.Telefon))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Telefon_{item.RowNumber}", string.Format(FelhasznalokResource.TelefonszamKotelezo, item.RowNumber));
|
|
}
|
|
else
|
|
{
|
|
var match = new Regex(RegularExpressions.Telefon).Match(item.Telefon);
|
|
if (!match.Success)
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Telefon_{item.RowNumber}", string.Format(FelhasznalokResource.TelefonszamHibas, item.RowNumber));
|
|
}
|
|
else if (!new PhoneAttribute().IsValid(item.Telefon))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Telefon_{item.RowNumber}", string.Format(FelhasznalokResource.TelefonszamHibas, item.RowNumber));
|
|
}
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(item.Email))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Email_{item.RowNumber}", string.Format(FelhasznalokResource.EmailCimKotelezo, item.RowNumber));
|
|
}
|
|
else
|
|
{
|
|
var tempByteArray = Encoding.GetEncoding(EncodingName.ISO_8859_8).GetBytes(item.Email);
|
|
var encodedString = Encoding.UTF8.GetString(tempByteArray);
|
|
if (!encodedString.Equals(item.Email))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Email_{item.RowNumber}", string.Format(FelhasznalokResource.EmailCimHibas, item.RowNumber));
|
|
}
|
|
else if (!new EmailAddressAttribute().IsValid(item.Email))
|
|
{
|
|
AddErrorMessage(errorDictionary, $"Email_{item.RowNumber}", string.Format(FelhasznalokResource.EmailCimHibas, item.RowNumber));
|
|
}
|
|
}
|
|
}
|
|
|
|
return !errorDictionary.Any();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|