95 lines
4.6 KiB
C#
95 lines
4.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using Kreta.BusinessLogic.Classes;
|
|
using Kreta.BusinessLogic.Exceptions;
|
|
using Kreta.BusinessLogic.HelperClasses;
|
|
using Kreta.BusinessLogic.Helpers;
|
|
using Kreta.BusinessLogic.Security;
|
|
using Kreta.Client.Leltar;
|
|
using Kreta.Core.Exceptions;
|
|
using Kreta.Enums.ManualEnums;
|
|
using Kreta.Resources;
|
|
using Kreta.Web.Areas.Alkalmazott.Models;
|
|
using Kreta.Web.Areas.Tanulo.Helper;
|
|
using Kreta.Web.Helpers;
|
|
using Kreta.Web.Helpers.Error;
|
|
using Kreta.Web.Security;
|
|
|
|
namespace Kreta.Web.Areas.Alkalmazott.ApiControllers
|
|
{
|
|
[ApiRoleClaimsAuthorize(true)]
|
|
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue, KretaClaimPackages.Dualis_Admin.ClaimValue)]
|
|
[Attributes.KretaGlobalLanguageChangeApiActionFilter(LanguageCode = "hu-Dualis")]
|
|
public class DualisAdminAlkalmazottApiController : BaseAlkalmazottApiController
|
|
{
|
|
public bool IsDualisKepzesEnabled => new IntezmenyConfigHelper(ConnectionTypeExtensions.GetSystemConnectionType()).GetIntezmenyConfig<bool>(IntezmenyConfigModulEnum.DualisKepzes, IntezmenyConfigTipusEnum.IsEnabled);
|
|
public DualisAdminAlkalmazottApiController(ILeltarClient leltarClient)
|
|
: base(leltarClient)
|
|
{
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage SaveDualisKepzohelyiOktato(DualisKepzohelyiOktatoModel model)
|
|
{
|
|
try
|
|
{
|
|
DualisKepzohelyiOktatoValidation(ModelState, model);
|
|
|
|
if (ModelState.IsValid)
|
|
{
|
|
return SaveDualisKepzohelyiOktato(model, IsDualisKepzesEnabled);
|
|
}
|
|
|
|
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
|
}
|
|
catch (Check4TValidacioExistsException)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, CommonResource.AMegadottFelhasznaloiAdatokkalMarLetezikFelhasznalo);
|
|
}
|
|
catch (BlException e)
|
|
{
|
|
var error = new StatusError(HttpStatusCode.BadRequest, e.Message);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
private void DualisKepzohelyiOktatoValidation(System.Web.Http.ModelBinding.ModelStateDictionary modelState, DualisKepzohelyiOktatoModel model)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(model.JogosultsagModel.BelepesiNev))
|
|
{
|
|
var felhasznaloHelper = new FelhasznaloHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
var tanevMegnevezes = GetTanevMegnevezesForBelepesCheck();
|
|
var anotherYearId = Classes.Utils.GetAnotherYearId();
|
|
var tanevIds = new List<int>
|
|
{
|
|
ClaimData.SelectedTanevID.Value
|
|
};
|
|
if (anotherYearId.HasValue)
|
|
{
|
|
tanevIds.Add(anotherYearId.Value);
|
|
}
|
|
|
|
var list = felhasznaloHelper.Check4TFelhOktAzonValidation(tanevIds, (int)Validation4TEnum.Alkalmazott,
|
|
"F", model.NevEloTag, model.CsaladiNev, model.Utonev,
|
|
"F", "", "", "",
|
|
"", null, "", model.JogosultsagModel.BelepesiNev);
|
|
|
|
var selectedTanevUtkozes = list.Where(x => (!model.OktatoSzervezetId.HasValue || (x.ID != model.OktatoSzervezetId && x.ElozoTanevRekordId != model.OktatoSzervezetId))
|
|
&& x.TanevId == ClaimData.SelectedTanevID.Value).ToList();
|
|
var anotherTanevUtkozes = list.Where(x => (!model.OktatoSzervezetId.HasValue || (x.ID != model.OktatoSzervezetId && x.ElozoTanevRekordId != model.OktatoSzervezetId))
|
|
&& anotherYearId.HasValue && x.TanevId == anotherYearId.Value).ToList();
|
|
|
|
var followUpolnivalo = new Felh4TOktAzonValidationCo();
|
|
|
|
var selectedTanevUtkozesForBejelentkezesiNev = selectedTanevUtkozes.Where(x => x.BejelentkezesiNev?.ToComparableString() == model.JogosultsagModel.BelepesiNev?.ToComparableString());
|
|
var anotherTanevUtkozesForBejelentkezesiNev = anotherYearId.HasValue && followUpolnivalo == null ? anotherTanevUtkozes.Where(x => x.BejelentkezesiNev?.ToComparableString() == model.JogosultsagModel.BelepesiNev?.ToComparableString()) : new List<Felh4TOktAzonValidationCo>();
|
|
|
|
TanuloLogic.FelhasznalonevValidacio(modelState, "JogosultsagModel.BelepesiNev", selectedTanevUtkozesForBejelentkezesiNev, anotherTanevUtkozesForBejelentkezesiNev, tanevMegnevezes);
|
|
}
|
|
}
|
|
}
|
|
}
|