226 lines
9 KiB
C#
226 lines
9 KiB
C#
namespace Kreta.Web.Areas.OsztalyCsoport.ApiControllers
|
|
{
|
|
using System;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using Kreta.BusinessLogic.Exceptions;
|
|
using Kreta.BusinessLogic.Helpers;
|
|
using Kreta.BusinessLogic.Security;
|
|
using Kreta.Core.Exceptions;
|
|
using Kreta.KretaServer.Exceptions;
|
|
using Kreta.Resources;
|
|
using Kreta.Web.Areas.OsztalyCsoport.Logic;
|
|
using Kreta.Web.Areas.OsztalyCsoport.Models;
|
|
using Kreta.Web.Helpers;
|
|
using Kreta.Web.Helpers.Error;
|
|
using Kreta.Web.Security;
|
|
|
|
[ApiRoleClaimsAuthorize(true)]
|
|
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
|
public class KovTanevSorolasApiController : ApiController
|
|
{
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage CsoportLeptetes(KovTanevCsoportAtleptetesModel model)
|
|
{
|
|
try
|
|
{
|
|
new OsztalyCsoportbaSorolasHelper(ConnectionTypeExtensions.GetSessionConnectionType(), ClaimData.IsSzakkepzoIntezmeny, ClaimData.IsSelectedTanev21_22OrLater, ClaimData.AktivTanevID, ClaimData.KovTanevID, kovTanev: true).CsoportLeptetes(model);
|
|
}
|
|
catch (BlException ex)
|
|
{
|
|
var error = StatusErrorFactory.GetSorolasStatusErrorWithReloadDDL(ex.Message);
|
|
if (ex.IsUnHandled)
|
|
{
|
|
error.UnHandledException = ex.InnerException;
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage CsoportBesorolas(KovTanevCsoportBesorolasModel model)
|
|
{
|
|
try
|
|
{
|
|
new OsztalyCsoportbaSorolasHelper(ConnectionTypeExtensions.GetSessionConnectionType(), ClaimData.IsSzakkepzoIntezmeny, ClaimData.IsSelectedTanev21_22OrLater, ClaimData.AktivTanevID, ClaimData.KovTanevID, kovTanev: true).CsoportbaSorolas(model);
|
|
}
|
|
catch (BlException ex)
|
|
{
|
|
var error = StatusErrorFactory.GetSorolasStatusError(ex.Message);
|
|
if (ex.IsUnHandled)
|
|
{
|
|
error.UnHandledException = ex.InnerException;
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage CsoportTevesBesorolasJavitas(KovTanevCsoportTevesBesorolasJavitasModel model)
|
|
{
|
|
try
|
|
{
|
|
new OsztalyCsoportbaSorolasHelper(ConnectionTypeExtensions.GetSessionConnectionType(), ClaimData.IsSzakkepzoIntezmeny, ClaimData.IsSelectedTanev21_22OrLater, ClaimData.AktivTanevID, ClaimData.KovTanevID, kovTanev: true).CsoportSorolasJavitas(model);
|
|
}
|
|
catch (BlException ex)
|
|
{
|
|
var error = StatusErrorFactory.GetSorolasStatusErrorWithReloadDDL(ex.Message);
|
|
if (ex.IsUnHandled)
|
|
{
|
|
error.UnHandledException = ex.InnerException;
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage NebuloBesorolas(KovTanevNebuloBesorolasModel model)
|
|
{
|
|
try
|
|
{
|
|
new OsztalyCsoportbaSorolasHelper(ConnectionTypeExtensions.GetSessionConnectionType(), ClaimData.IsSzakkepzoIntezmeny, ClaimData.IsSelectedTanev21_22OrLater, ClaimData.AktivTanevID, ClaimData.KovTanevID, kovTanev: true).NebuloMentes(model, ClaimData.IsSzirIntezmeny);
|
|
}
|
|
catch (BlException ex)
|
|
{
|
|
var error = StatusErrorFactory.GetSorolasStatusErrorWithReloadDDL(ex.Message);
|
|
if (ex.IsUnHandled)
|
|
{
|
|
error.UnHandledException = ex.InnerException;
|
|
}
|
|
throw error;
|
|
}
|
|
catch (KretaException e)
|
|
{
|
|
if (e is OktatasiAzonositoExistsException)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, $"{e.Message}{Core.Constants.General.Sortores}{ErrorResource.EzzelAzOktatasiAzonositovalMarRegisztraltakTanulotEbbeATanevbe}");
|
|
}
|
|
throw new StatusError(HttpStatusCode.BadRequest, e.Message) { UnHandledException = e };
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAMuveletSoran) { UnHandledException = e };
|
|
}
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage OsztalyLeptetes(KovTanevOsztalyAtleptetesModel model)
|
|
{
|
|
try
|
|
{
|
|
new OsztalyCsoportbaSorolasHelper(ConnectionTypeExtensions.GetSessionConnectionType(), ClaimData.IsSzakkepzoIntezmeny, ClaimData.IsSelectedTanev21_22OrLater, ClaimData.AktivTanevID, ClaimData.KovTanevID, kovTanev: true).OsztalyLeptetes(model);
|
|
}
|
|
catch (BlException ex)
|
|
{
|
|
var error = StatusErrorFactory.GetSorolasStatusErrorWithReloadDDL(ex.Message);
|
|
if (ex.IsUnHandled)
|
|
{
|
|
error.UnHandledException = ex.InnerException;
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage OsztalyBesorolasElsoAlkalom(KovTanevOsztalyBesorolasElsoAlkalomModel model)
|
|
{
|
|
try
|
|
{
|
|
new OsztalyCsoportbaSorolasHelper(ConnectionTypeExtensions.GetSessionConnectionType(), ClaimData.IsSzakkepzoIntezmeny, ClaimData.IsSelectedTanev21_22OrLater, ClaimData.AktivTanevID, ClaimData.KovTanevID, kovTanev: true).OsztalybaSorolasElsoAlkalommal(model);
|
|
}
|
|
catch (BlException ex)
|
|
{
|
|
var error = StatusErrorFactory.GetSorolasStatusErrorWithReloadDDL(ex.Message);
|
|
if (ex.IsUnHandled)
|
|
{
|
|
error.UnHandledException = ex.InnerException;
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage OsztalyTevesBesorolasJavitas(KovTanevOsztalyTevesBesorolasJavitasModel model)
|
|
{
|
|
try
|
|
{
|
|
new OsztalyCsoportbaSorolasHelper(ConnectionTypeExtensions.GetSessionConnectionType(), ClaimData.IsSzakkepzoIntezmeny, ClaimData.IsSelectedTanev21_22OrLater, ClaimData.AktivTanevID, ClaimData.KovTanevID, kovTanev: true).OsztalybaSorolasJavitasa(model);
|
|
}
|
|
catch (BlException ex)
|
|
{
|
|
var error = StatusErrorFactory.GetSorolasStatusErrorWithReloadDDL(ex.Message);
|
|
if (ex.IsUnHandled)
|
|
{
|
|
error.UnHandledException = ex.InnerException;
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage OsztalyVisszairatkoztatas(KovTanevVisszairatkoztatasModel model)
|
|
{
|
|
try
|
|
{
|
|
OsztalyCsoportLogic.KovTanevVisszairatkoztatasJogviszonyCustomValidation(ModelState, model);
|
|
|
|
if (ModelState.IsValid)
|
|
{
|
|
try
|
|
{
|
|
new OsztalyCsoportbaSorolasHelper(
|
|
ConnectionTypeExtensions.GetSessionConnectionType(),
|
|
ClaimData.IsSzakkepzoIntezmeny,
|
|
ClaimData.IsSelectedTanev21_22OrLater,
|
|
ClaimData.AktivTanevID,
|
|
ClaimData.KovTanevID,
|
|
true).VisszaIratkoztatas(model, model.ConvertModelToJogviszonyCo());
|
|
}
|
|
catch (BlException e)
|
|
{
|
|
var error = new StatusError(HttpStatusCode.BadRequest, e.Message);
|
|
throw error;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
|
}
|
|
}
|
|
catch (BlException ex)
|
|
{
|
|
var error = StatusErrorFactory.GetSorolasStatusErrorWithReloadDDL(ex.Message);
|
|
if (ex.IsUnHandled)
|
|
{
|
|
error.UnHandledException = ex.InnerException;
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
}
|
|
}
|