init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,414 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.ModelBinding;
|
||||
using System.Web.Http.Results;
|
||||
using Kendo.Mvc.UI;
|
||||
using Kreta.BusinessLogic.Classes.ComboBox;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Logic;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Core;
|
||||
using Kreta.Enums.ManualEnums;
|
||||
using Kreta.Framework.Entities;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Tantargy.Models;
|
||||
using Kreta.Web.Areas.TanuloErtekeles.Models.TanuloErtekeles;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Helpers.Error;
|
||||
using Kreta.Web.Helpers.Grid;
|
||||
using Kreta.Web.Security;
|
||||
using Newtonsoft.Json;
|
||||
using SDA.DataProvider;
|
||||
|
||||
namespace Kreta.Web.Areas.Tantargy.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public class TantargyakApiController : ApiController
|
||||
{
|
||||
public bool IsDualisKepzesEnabled => new IntezmenyConfigHelper(ConnectionTypeExtensions.GetSystemConnectionType()).GetIntezmenyConfig<bool>(IntezmenyConfigModulEnum.DualisKepzes, IntezmenyConfigTipusEnum.IsEnabled);
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public DataSourceResult GetTantargyakGrid(string data, DataSourceRequest request)
|
||||
{
|
||||
var (gridParameter, modelList) = GetGridData(data, request, IsDualisKepzesEnabled);
|
||||
|
||||
return modelList.ToDataSourceResult(gridParameter);
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public HttpResponseMessage GetExport(string data, DataSourceRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var (gridParameter, modelList) = GetGridData(data, request, IsDualisKepzesEnabled);
|
||||
|
||||
modelList = modelList.SortingAndPaging(gridParameter.OrderDictionary);
|
||||
|
||||
var simpleExportColumnCos = SimpleExportLogic.GetSimpleExportColumnCos<TantargyakGridModel>(TantargyakGridModel.TantargyakExportAttributeId);
|
||||
|
||||
var memoryStream = SimpleExportLogic.GetExport(TantargyResource.ExportSheetName, simpleExportColumnCos, modelList, ClaimData.SelectedTanevID.Value);
|
||||
|
||||
return HttpResponseExtensions.GetFileHttpResponse(memoryStream.ToArray(), $"{TantargyResource.Tantargyak_Export}_{DateTime.Now:yyyy_MM_dd}.xlsx");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAFajlExportalasaKozben) { UnHandledException = ex };
|
||||
}
|
||||
}
|
||||
|
||||
private (GridParameters gridParameter, List<TantargyakGridModel> modelList) GetGridData(string data, DataSourceRequest request, bool isFromSzervezet)
|
||||
{
|
||||
var model = JsonConvert.DeserializeObject<TantargySearchModel>(data);
|
||||
model.IsFromSzervezet = isFromSzervezet;
|
||||
model.IsSzakkepzo = ClaimData.IsSzakkepzoIntezmeny;
|
||||
|
||||
var gridParameter = Converter.GridParameter(request);
|
||||
|
||||
var coList = new TantargyHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetTantargyCoList(model.ConvertToCo());
|
||||
|
||||
var modelList = new List<TantargyakGridModel>();
|
||||
foreach (var co in coList)
|
||||
{
|
||||
var gridModel = new TantargyakGridModel(co);
|
||||
modelList.Add(gridModel);
|
||||
}
|
||||
|
||||
return (gridParameter, modelList);
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public DataSourceResult GetTantargyFoglalkozasaiGrid(int tantargyID, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var fhelper = new TantargyFelosztasHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
fhelper.GridParameters = Converter.GridParameter(request);
|
||||
var foglalkozasok = fhelper.GetTantargyFoglalkozasai(tantargyID);
|
||||
return foglalkozasok.ToDataSourceResult();
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public DataSourceResult GetTantargyOrarendiOraiGrid(int tantargyID, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var ohelper = new OrarendiOraHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
ohelper.GridParameters = Converter.GridParameter(request);
|
||||
var orarendiorak = ohelper.GetOrarendiOrakByTantargyId(tantargyID);
|
||||
return orarendiorak.ToDataSourceResult();
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public DataSourceResult GetTantargyTanmeneteiGrid(int tantargyID, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var thelper = new TanmenetHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
thelper.GridParameters = Converter.GridParameter(request);
|
||||
var tanmenetek = thelper.GetTantargyTanmenetei(tantargyID);
|
||||
return tanmenetek.ToDataSourceResult();
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public DataSourceResult GetTantargyMegtartottTanoraiGrid(int tantargyID, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var thelper = new TanoraHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
thelper.GridParameters = Converter.GridParameter(request);
|
||||
var tanmenetek = thelper.GetTantargyMegtartottTanorai(tantargyID);
|
||||
return tanmenetek.ToDataSourceResult();
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public DataSourceResult GetTantargyErtekelesListGrid(int tantargyId, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var helper = new TanuloErtekelesHelper(ConnectionTypeExtensions.GetSessionConnectionType())
|
||||
{
|
||||
GridParameters = Converter.GridParameter(request)
|
||||
};
|
||||
|
||||
var tanuloErtekelesListModel = new TanuloErtekelesListModel
|
||||
{
|
||||
TantargyIdSearch = tantargyId,
|
||||
FeladatKategoriaIdSearch = Constants.MindenErteke.FeladatKategoria
|
||||
};
|
||||
DataSet dataSet = helper.GetTanuloErtekelesListGridDataSet(tanuloErtekelesListModel.ToCo());
|
||||
|
||||
return dataSet.ToDataSourceResult();
|
||||
}
|
||||
|
||||
public HttpResponseMessage SaveModifiedOrNewTantargy(TantargyModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidateModel(model);
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
TantargyHelper h = new TantargyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
TantargyCO co = Convert_Model_to_CO(model);
|
||||
|
||||
h.SaveOrUpdateTantargy(co);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
catch (UniqueKeyViolationException)
|
||||
{
|
||||
/*Már létezik ilyen nevű tantárgy*/
|
||||
StatusError error = new StatusError(HttpStatusCode.BadRequest, StringResourcesUtils.GetString(4850));
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public HttpResponseMessage SaveModTantargy(TantargyModModel model)
|
||||
{
|
||||
bool? isFoTargyE = default;
|
||||
if (model.IsFoTargy.HasValue)
|
||||
{
|
||||
isFoTargyE = model.IsFoTargy > 0;
|
||||
}
|
||||
|
||||
bool? isGyakorlatiTargy = default;
|
||||
if (model.GyakorlatiTargy.HasValue)
|
||||
{ isGyakorlatiTargy = model.GyakorlatiTargy > 0; }
|
||||
|
||||
bool? isAmiTargy = default;
|
||||
if (model.IsAmiTargyMod.HasValue)
|
||||
{ isAmiTargy = model.IsAmiTargyMod > 0; }
|
||||
|
||||
bool? isMszgTargy = default;
|
||||
if (model.IsMszgTargyMod.HasValue)
|
||||
{ isMszgTargy = model.IsMszgTargyMod > 0; }
|
||||
|
||||
bool? isKollegiumiTargy = default;
|
||||
if (model.IsKollegiumiTargy.HasValue)
|
||||
{ isKollegiumiTargy = model.IsKollegiumiTargy > 0; }
|
||||
|
||||
bool? isFelnottoktatasTargy = default;
|
||||
if (model.IsFelnottOktatasTargy.HasValue)
|
||||
{ isFelnottoktatasTargy = model.IsFelnottOktatasTargy > 0; }
|
||||
|
||||
bool? isNincsBeloleOra = default;
|
||||
if (model.IsNincsBeloleOraMod.HasValue)
|
||||
{ isNincsBeloleOra = model.IsNincsBeloleOraMod > 0; }
|
||||
|
||||
bool? isEgymiTargy = default;
|
||||
if (model.IsEgymiTargyMod.HasValue)
|
||||
{ isEgymiTargy = model.IsEgymiTargyMod > 0; }
|
||||
|
||||
int? sorszam = model.Sorszam;
|
||||
|
||||
bool? isAltantargyNyomtatvanyban = default;
|
||||
if (model.AltantargyNyomtatvanyban.HasValue)
|
||||
{ isAltantargyNyomtatvanyban = model.AltantargyNyomtatvanyban > 0; }
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(model.TantargyakIDArray))
|
||||
{
|
||||
var h = new TantargyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var co = new TantargyTobbesModositasCO(model.ID.Value, model.TargyKategoria, model.ESLTargyKategoria, isFoTargyE, isGyakorlatiTargy, isAltantargyNyomtatvanyban, model.FoTargyID, sorszam, isAmiTargy, isMszgTargy, isKollegiumiTargy, isFelnottoktatasTargy, isEgymiTargy, isNincsBeloleOra);
|
||||
h.TantargyTobbesModify(co);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] tantargyIDArray = model.TantargyakIDArray.Split(',');
|
||||
|
||||
var h = new TantargyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
foreach (var item in tantargyIDArray)
|
||||
{
|
||||
var co = new TantargyTobbesModositasCO(int.Parse(item), model.TargyKategoria, model.ESLTargyKategoria, isFoTargyE, isGyakorlatiTargy, isAltantargyNyomtatvanyban, model.FoTargyID, sorszam, isAmiTargy, isMszgTargy, isKollegiumiTargy, isFelnottoktatasTargy, isEgymiTargy, isNincsBeloleOra);
|
||||
h.TantargyTobbesModify(co);
|
||||
}
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteTantargy([FromBody] int tantargyID)
|
||||
{
|
||||
try
|
||||
{
|
||||
TantargyHelper h = new TantargyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
h.DeleteTantargyById(tantargyID);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (EntityDeleteFailedException ex)
|
||||
{
|
||||
var uzenet = string.Format(ErrorResource.NemTorolhetoKapcsolatMiatt, TantargyResource.Tantargy, ex.ConnectionErrorMessage);
|
||||
throw new StatusError(HttpStatusCode.BadRequest, uzenet);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public IHttpActionResult DeleteSelectedTantargy(List<int> idList)
|
||||
{
|
||||
var connectionType = ConnectionTypeExtensions.GetSessionConnectionType();
|
||||
var h = new TantargyHelper(connectionType);
|
||||
|
||||
var errorMsg = string.Empty;
|
||||
var counter = 0;
|
||||
foreach (var id in idList)
|
||||
{
|
||||
try
|
||||
{
|
||||
h.DeleteTantargyById(id, false);
|
||||
counter++;
|
||||
}
|
||||
catch (EntityDeleteFailedException ex)
|
||||
{
|
||||
var tantargyNev = h.GetTantargyById(id).TantargyNev;
|
||||
var errorMessage = string.Format(ErrorResource.NemTorolhetoKapcsolatMiatt, tantargyNev, ex.ConnectionErrorMessage);
|
||||
|
||||
errorMsg += $"{errorMessage}{Environment.NewLine}{Environment.NewLine}";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (idList.Any())
|
||||
{
|
||||
new TanoraHelper(connectionType).UpdateTanitasiOraEvesSorszamTeljesTanev();
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(errorMsg))
|
||||
{
|
||||
return Json(new { Message = string.Format(ErrorResource.NSorTorlesSikeres, counter) });
|
||||
}
|
||||
|
||||
if (counter > 0)
|
||||
{
|
||||
errorMsg += Environment.NewLine + string.Format(ErrorResource.NSorTorlesSikeres, counter);
|
||||
}
|
||||
throw new StatusError(HttpStatusCode.BadRequest, errorMsg);
|
||||
}
|
||||
|
||||
private TantargyCO Convert_Model_to_CO(TantargyModel model)
|
||||
{
|
||||
TantargyCO co = new TantargyCO
|
||||
{
|
||||
AltantargyNyomtatvanyban = model.AltantargyNyomtatvanyban,
|
||||
FoTargyID = model.FoTargyID,
|
||||
FoTargyNev = model.FoTargyNev,
|
||||
GyakorlatiTargy = model.GyakorlatiTargy,
|
||||
ID = model.ID,
|
||||
isFoTargy = model.IsFoTargy,
|
||||
NevNyomtatvanyban = model.NevNyomtatvanyban,
|
||||
TantargyNev = model.TantargyNev,
|
||||
TantargyRovidNev = model.TantargyRovidNev,
|
||||
TargyKategoria = model.TargyKategoria,
|
||||
TargyKategoriaNev = model.TargyKategoriaNev,
|
||||
ESLTantargykategoria = model.ESLTargyKategoria,
|
||||
ESLTantargykategoriaNev = model.ESLTargyKategoriaNev,
|
||||
TantargyAngolNev = model.TantargyAngolNev,
|
||||
TantargyNemetNev = model.TantargyNemetNev,
|
||||
TantargyHorvatNev = model.TantargyHorvatNev,
|
||||
TantargyRomanNev = model.TantargyRomanNev,
|
||||
TantargySzerbNev = model.TantargySzerbNev,
|
||||
Sorszam = model.Sorszam,
|
||||
Megjegyzes = model.Megjegyzes,
|
||||
Gyakorlatigenyesseg = model.Gyakorlatigenyesseg,
|
||||
IsAmiTargy = model.IsAmiTargyMod,
|
||||
IsKollegiumiTargy = model.IsKollegiumiTargy,
|
||||
IsFelnottOktatasTargy = model.IsFelnottOktatas,
|
||||
IsNincsBeloleOra = model.IsNincsBeloleOraMod,
|
||||
IsEgymiTargy = model.IsEgymi,
|
||||
IsTanulmanyiAtlagbaNemSzamit = model.IsTanulmanyiAtlagbaNemSzamit,
|
||||
IsOsztalynaplobanNemJelenikMeg = model.IsOsztalynaplobanNemJelenikMeg,
|
||||
IsOsztalyokOrarendjebenMegjelenik = model.IsOsztalyOrarendjebenMegjelenik,
|
||||
IsMszgTargy = model.IsMszgTargy,
|
||||
MufajTipusId = model.AmiKepzesiJellemzokModel.MufajTipusId,
|
||||
TanszakTipusId = model.AmiKepzesiJellemzokModel.TanszakTipusId,
|
||||
MuveszetiAgId = model.AmiKepzesiJellemzokModel.MuveszetiAgId
|
||||
};
|
||||
|
||||
co.SetErtekelesKorlatozasok(model.ErtekelesKorlatozasIdList);
|
||||
|
||||
return co;
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetFotargyakList([DataSourceRequest] DataSourceRequest request)
|
||||
{
|
||||
var helper = new TantargyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var dictionary = helper.GetFotargyak();
|
||||
List<ComboBoxListItem> dropdownListItems = new List<ComboBoxListItem>();
|
||||
|
||||
foreach (var item in dictionary)
|
||||
{
|
||||
ComboBoxListItem sli = new ComboBoxListItem() { Text = item.Value, Value = item.Key };
|
||||
dropdownListItems.Add(sli);
|
||||
}
|
||||
return Json(dropdownListItems);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public IHttpActionResult GetFotargyakhozTartozikAltargy(List<int> tantargyIdList)
|
||||
{
|
||||
if (tantargyIdList.Any())
|
||||
{
|
||||
TantargyHelper h = new TantargyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
List<string> errorList = h.GetFotargyhozTartozikAltargy(tantargyIdList);
|
||||
string errorMsg = string.Empty, entityName = string.Empty;
|
||||
if (errorList.Any())
|
||||
{
|
||||
errorMsg += $"{TantargyResource.AFotargyNemAllithatoAltarggyaMivelTartozikHozzaAltantargy}{Environment.NewLine}{string.Join(Environment.NewLine + " ", errorList)}";
|
||||
throw new StatusError(HttpStatusCode.BadRequest, errorMsg);
|
||||
}
|
||||
|
||||
}
|
||||
return Json(new { Text = "" });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public IHttpActionResult GetSzorgalomElegtelenTantargyList(List<int> tantargyIdList)
|
||||
{
|
||||
TantargyHelper h = new TantargyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var tantargyList = h.GetTantargyakEgyesErtekelessel(tantargyIdList);
|
||||
|
||||
return Json(JsonConvert.SerializeObject(tantargyList));
|
||||
}
|
||||
|
||||
private void ValidateModel(TantargyModel model)
|
||||
{
|
||||
if (model.IsAmiTargyMod && model.IsMszgTargy)
|
||||
{
|
||||
ModelState.AddModelError(nameof(model.IsAmiTargyMod), TantargyResource.AmiMszgTargyValidacioHiba);
|
||||
}
|
||||
|
||||
if (model.TantargyNev == TantargyResource.DualisKepzes)
|
||||
{
|
||||
ModelState.AddModelError(nameof(model.TantargyNev), TantargyResource.DualisKepzesTantargyNemModosithatoMertVedettElem);
|
||||
}
|
||||
else if (model.TantargyNev == TantargyResource.ApaczaiKonzultacio)
|
||||
{
|
||||
ModelState.AddModelError(nameof(model.TantargyNev), TantargyResource.ApaczaiKonzultacioTantargyNemModosithatoMertVedettElem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue