100 lines
3.7 KiB
C#
100 lines
3.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Runtime.Caching;
|
|
using System.Text;
|
|
using System.Web.Mvc;
|
|
using Kreta.BusinessLogic.Helpers;
|
|
using Kreta.BusinessLogic.Security;
|
|
using Kreta.Framework;
|
|
using Kreta.Resources;
|
|
using Kreta.Web.Areas.Adminisztracio.ApiControllers;
|
|
using Kreta.Web.Areas.Adminisztracio.Models;
|
|
using Kreta.Web.Controllers.Logic;
|
|
using Kreta.Web.Helpers;
|
|
using Kreta.Web.Helpers.Error;
|
|
using Kreta.Web.Security;
|
|
|
|
namespace Kreta.Web.Areas.Adminisztracio.Controllers
|
|
{
|
|
[MvcRoleClaimsAuthorize(true)]
|
|
[MvcRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
|
[MvcRolePackageDenyAuthorize(KretaClaimPackages.IsOnlyAlkalmozott.ClaimValue)]
|
|
public class AktivTanevValtasaController : Controller
|
|
{
|
|
public ActionResult Index()
|
|
=> View("Index", new AktivTanevValtasaApiController().GetAktivTanevValtasaModel());
|
|
|
|
[HttpPost]
|
|
[MvcRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
|
public ActionResult AktivTanevValtasa(int? kiNemSoroltTanulokOsztaly, int? alkalmazottakAlapertekekkel)
|
|
{
|
|
if (ClaimData.KovTanevID.HasValue && (!alkalmazottakAlapertekekkel.HasValue || alkalmazottakAlapertekekkel.Value == 0))
|
|
{
|
|
if ((!kiNemSoroltTanulokOsztaly.HasValue || kiNemSoroltTanulokOsztaly.Value == 0))
|
|
{
|
|
try
|
|
{
|
|
var cache = MemoryCache.Default;
|
|
cache.Remove($"{ClaimData.IntezmenyAzonosito}_mobileIntezmenyAdatok");
|
|
|
|
new AdminHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).AktivTanevValtasa(ClaimData.SelectedTanevID.Value, ClaimData.KovTanevID.Value);
|
|
|
|
HttpContext.Items.Remove(nameof(UserContext));
|
|
|
|
new AdminHelper(ConnectionTypeExtensions.GetSystemConnectionType()).ElozoTanevesViewokTorlese(ClaimData.KovTanevID.Value);
|
|
|
|
MasterLayoutLogic.LogOut();
|
|
|
|
return new JsonResult()
|
|
{
|
|
Data = new
|
|
{
|
|
url = Url.Action("Index", "Login", new { area = "Adminisztracio" })
|
|
}
|
|
};
|
|
}
|
|
catch
|
|
{
|
|
return new HttpStatusCodeResult(500);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return new HttpStatusCodeResult(400);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return new HttpStatusCodeResult(406);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[MvcRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
|
public ActionResult AlkalmazottTorles(List<TanevValtasAlkalmazottTorlesGridModel> torlendoAlkalmazottak)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (var item in torlendoAlkalmazottak)
|
|
{
|
|
try
|
|
{
|
|
new AlkalmazottHelper(ConnectionTypeExtensions.GetNextSessionConnectionType()).DeleteAlkalmazott(item.AlkalmazottId.Value);
|
|
}
|
|
catch
|
|
{
|
|
sb.AppendFormat(AdminisztracioResource.AlkalmazottTorlesNemSikerult, item.AlkalmazottNev);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (sb.Length > 0)
|
|
{
|
|
sb.Append(AdminisztracioResource.FolytatjaTanevValtast);
|
|
throw new StatusError(500, sb.ToString());
|
|
}
|
|
else
|
|
{
|
|
return new JsonResult();
|
|
}
|
|
}
|
|
}
|
|
}
|