init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,162 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Interfaces;
|
||||
using Kreta.BusinessLogic.Logic;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Client.CoreApi;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.Exceptions;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Enums.ManualEnums;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Orarend.Models;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Helpers.Error;
|
||||
using Kreta.Web.Helpers.Grid;
|
||||
using Kreta.Web.Security;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kreta.Web.Areas.Orarend.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public class TanoraKeresoApiController : ApiController
|
||||
{
|
||||
private IKretaAuthorization Authorization { get; }
|
||||
|
||||
private readonly IFileServiceHelper fileServiceHelper;
|
||||
private readonly ICoreApiClient coreApiClient;
|
||||
|
||||
public TanoraKeresoApiController(IKretaAuthorization authorization, IFileServiceHelper fileServiceHelper, ICoreApiClient coreApiClient)
|
||||
{
|
||||
Authorization = authorization;
|
||||
this.fileServiceHelper = fileServiceHelper ?? throw new ArgumentNullException(nameof(fileServiceHelper));
|
||||
this.coreApiClient = coreApiClient ?? throw new ArgumentNullException(nameof(coreApiClient));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public DataSourceResult GetTanitasiOraGrid([ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] KretaGridDataSourceRequest request)
|
||||
{
|
||||
var (gridParameter, modelList) = GetGridData(request.data, request);
|
||||
|
||||
return modelList.ToDataSourceResult(gridParameter);
|
||||
}
|
||||
|
||||
public HttpResponseMessage GetExport(string data, DataSourceRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var (gridParameter, modelList) = GetGridData(data, request);
|
||||
|
||||
modelList = modelList.SortingAndPaging(gridParameter.OrderDictionary);
|
||||
|
||||
var simpleExportColumnCos = SimpleExportLogic.GetSimpleExportColumnCos<TanitasiOraGridModel>(TanitasiOraGridModel.TanoraExportAttributeId);
|
||||
|
||||
var memoryStream = SimpleExportLogic.GetExport(OrarendResource.Tanorak, simpleExportColumnCos, modelList, ClaimData.SelectedTanevID.Value);
|
||||
|
||||
return HttpResponseExtensions.GetFileHttpResponse(memoryStream.ToArray(), OrarendResource.ExportFileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAFajlExportalasaKozben) { UnHandledException = ex };
|
||||
}
|
||||
}
|
||||
|
||||
private (GridParameters gridParameter, List<TanitasiOraGridModel> modelList) GetGridData(string data, DataSourceRequest request)
|
||||
{
|
||||
var model = JsonConvert.DeserializeObject<TanitasiOraSearchModel>(data);
|
||||
|
||||
var gridParameter = Converter.GridParameter(request);
|
||||
|
||||
var coList = new TanoraHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetTanitasiOraCoList(TanitasiOraSearchModel.ConvertModelToCo(model));
|
||||
|
||||
var modelList = new List<TanitasiOraGridModel>();
|
||||
|
||||
foreach (var co in coList)
|
||||
{
|
||||
var gridModel = new TanitasiOraGridModel(co);
|
||||
modelList.Add(gridModel);
|
||||
}
|
||||
|
||||
return (gridParameter, modelList);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public bool DeleteTanora(int tanoraId)
|
||||
{
|
||||
try
|
||||
{
|
||||
TanoraCO tanora;
|
||||
var helper = new TanoraHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
tanora = helper.GetTanorakAdatok(tanoraId);
|
||||
|
||||
var calendarModel = new CalendarModel();
|
||||
calendarModel.Start = tanora.OraKezd;
|
||||
calendarModel.End = tanora.OraVeg;
|
||||
calendarModel.EventId = tanoraId;
|
||||
calendarModel.EventType = EventTypeEnum.LetezoOraSzerkesztese;
|
||||
calendarModel.AllDay = false;
|
||||
calendarModel.EventColor = string.Empty;
|
||||
calendarModel.OraType = CalendarOraTypeEnum.TanitasiOra;
|
||||
calendarModel.HelyettesitesId = tanora.HelyettesitesId;
|
||||
calendarModel.HelyettesitoId = tanora.Helyettesito;
|
||||
calendarModel.UseFoglakozas = tanora.Fogl.HasValue;
|
||||
calendarModel.isHelyettesites = tanora.Helyettesito.HasValue;
|
||||
calendarModel.IsOraOsszevonas = tanora.HelyettesitesTipus == (int)HelyettesitesTipusEnum.oraosszevonas;
|
||||
calendarModel.Tema = tanora.Tema;
|
||||
|
||||
if (!tanora.Tanar.HasValue)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAMuveletSoran);
|
||||
}
|
||||
|
||||
var muveletPram = new TanoraMuveletek(tanora.Tanar.Value, calendarModel);
|
||||
|
||||
using (var tanariOrarend = new TanariOrarendApiController(Authorization, fileServiceHelper, coreApiClient))
|
||||
{
|
||||
tanariOrarend.DeleteTanora(muveletPram);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (BlException ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetCsoportTipusList([DataSourceRequest] DataSourceRequest request)
|
||||
{
|
||||
var dictionary = FrameworkEnumExtensions.EnumToList((int)GeneratedAdatszotarTipusEnum.CsoportTipus, ClaimData.SelectedTanevID.Value, false);
|
||||
return Json(dictionary.ToComboBoxItemList());
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetFoglalkozasList([DataSourceRequest] DataSourceRequest request)
|
||||
{
|
||||
var foglalkozasHelper = new FoglalkozasHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
var dictionary = foglalkozasHelper.GetOsszesFoglalkozas();
|
||||
return Json(dictionary.ToComboBoxItemList());
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetTantargyList([DataSourceRequest] DataSourceRequest request)
|
||||
{
|
||||
var helper = new TantargyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
var dictionary = helper.GetTantargyakForDDL(isSzakkepzo: ClaimData.IsSzakkepzoIntezmeny);
|
||||
return Json(dictionary.ToComboBoxItemList());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue