init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,163 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Results;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.HelperClasses.OsztalyCsoportbaSorolas;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.Core.Exceptions;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.OsztalyCsoport.Models;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Helpers.Error;
|
||||
using Kreta.Web.Models;
|
||||
using Kreta.Web.Security;
|
||||
|
||||
namespace Kreta.Web.Areas.OsztalyCsoport.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[MvcRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue, KretaClaimPackages.Osztalyfonok.ClaimValue)]
|
||||
public class ZaradekApiController : ApiController
|
||||
{
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveZaradek(SorolasZaradek model)
|
||||
{
|
||||
if (!ValidateZaradek(model, out var errorDictionary))
|
||||
{
|
||||
ModelState.AddRange(errorDictionary);
|
||||
}
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var helper = new ZaradekHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.SaveZaradek(model.ConvertToCo(), ClaimData.IsOsztalyfonok, ClaimData.IsAdministrator);
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
catch (BlException ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.InternalServerError, ex.Message, ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.InternalServerError, ErrorResource.NemSikerultAMuvelet, ex);
|
||||
}
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteZaradek(int zaradekId)
|
||||
{
|
||||
try
|
||||
{
|
||||
new ZaradekHelper(ConnectionTypeExtensions.GetSessionConnectionType()).DeleteZaradek(zaradekId, ClaimData.IsOsztalyfonok);
|
||||
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
catch (BlException ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.InternalServerError, ErrorResource.NemSikerultAMuvelet, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ValidateZaradek(SorolasZaradek model, out Dictionary<string, List<string>> errorDictionary)
|
||||
{
|
||||
errorDictionary = new Dictionary<string, List<string>>();
|
||||
|
||||
if (model.ZaradekSzovegList == null || !model.ZaradekSzovegList.Any(z => z.NyelvId == (int)AnyanyelvEnum.magyar && !string.IsNullOrWhiteSpace(z.Szoveg)))
|
||||
{
|
||||
errorDictionary.Add($"ZaradekSzovegTextArea_{(int)AnyanyelvEnum.magyar}", new List<string> { OsztalyCsoportResource.ZaradekSzovegeKotelezo });
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(model.KeltezesHelye))
|
||||
{
|
||||
errorDictionary.Add($"KeltezesHelye", new List<string> { OsztalyCsoportResource.KeltezesHelyeKotelezo });
|
||||
}
|
||||
if (!model.KeltezesDatuma.HasValue)
|
||||
{
|
||||
errorDictionary.Add($"KeltezesDatuma", new List<string> { OsztalyCsoportResource.KeltezesDatumaKotelezo });
|
||||
}
|
||||
return !errorDictionary.Any();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public JsonResult<ZaradekMegjeleniteseModel> GetZaradekMegjelenese(int adatszotarId)
|
||||
{
|
||||
var helper = new AdatszotarHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
AdatszotarCO co = helper.GetAdatszotarElem(adatszotarId);
|
||||
|
||||
var result = new ZaradekMegjeleniteseModel();
|
||||
|
||||
result.ZaradekSzovegList = new List<ZaradekNyelvCo> { new ZaradekNyelvCo { NyelvId = (int)AnyanyelvEnum.magyar, Szoveg = co.Megnevezes } };
|
||||
result.ZaradekSzovegList.AddRange(co.ZaradekSzovegCoList.ConvertAll(x => new ZaradekNyelvCo { NyelvId = x.NyelvId, Szoveg = x.Name }).ToList());
|
||||
result.IsBizonyitvanMegjelenes = co.IsBizonyitvanybanMegjelenik;
|
||||
result.IsTorzslapMegjelenes = co.IsTorzslaponMegjelenik;
|
||||
result.IsNaploMegjelenes = co.IsNaplobanMegjelenik;
|
||||
|
||||
return Json(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveZaradekTobbesModositas(ZaradekTobbesModositasaModel model)
|
||||
{
|
||||
if (!ValidateZaradek(model.SorolasZaradekModel, out var errorDictionary))
|
||||
{
|
||||
ModelState.AddRange(errorDictionary);
|
||||
}
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var helper = new ZaradekHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.SaveZaradekTobbesModositas(model.SorolasZaradekModel.ConvertToCo(), ClaimData.IsOsztalyfonok, ClaimData.IsAdministrator, model.TanuloCsoportIdList);
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
catch (BlException ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.InternalServerError, ex.Message, ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.InternalServerError, ErrorResource.NemSikerultAMuvelet, ex);
|
||||
}
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage OsszesZaradekTorlese(ZaradekTobbesModositasaModel model)
|
||||
{
|
||||
var helper = new ZaradekHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.OsszesZaradekTorlese(model.TanuloCsoportIdList, model.IsOsztalyList);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage LegutobbRogzitettZaradekTorlese(ZaradekTobbesModositasaModel model)
|
||||
{
|
||||
var helper = new ZaradekHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.LegutobbRogzitettZaradekokTorlese(model.TanuloCsoportIdList, model.IsOsztalyList);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue