init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,773 @@
|
|||
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;
|
||||
using Kreta.BusinessLogic.Classes.ComboBox;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Helpers.SystemSettings;
|
||||
using Kreta.BusinessLogic.Interfaces;
|
||||
using Kreta.BusinessLogic.Logic.Mulasztas;
|
||||
using Kreta.BusinessLogic.Logic.Naplozas;
|
||||
using Kreta.BusinessLogic.Logic.Naplozas.Elokeszites;
|
||||
using Kreta.BusinessLogic.Logic.Naplozas.Validacio;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Client.CoreApi;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.Exceptions;
|
||||
using Kreta.Core.Validation.Exceptions;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Enums.ManualEnums;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Intezmeny.Logic;
|
||||
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.Linq;
|
||||
|
||||
namespace Kreta.Web.Areas.Orarend.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Naplo.ClaimValue)]
|
||||
public class TanariOrarendApiController : BaseTanariOrarendApiController
|
||||
{
|
||||
private IKretaAuthorization Authorization { get; }
|
||||
|
||||
private readonly IFileServiceHelper _fileServiceHelper;
|
||||
private readonly ICoreApiClient _coreApiClient;
|
||||
|
||||
public TanariOrarendApiController(IKretaAuthorization authorization, IFileServiceHelper fileServiceHelper, ICoreApiClient coreApiClient) : base(authorization, fileServiceHelper, coreApiClient)
|
||||
{
|
||||
Authorization = authorization;
|
||||
_fileServiceHelper = fileServiceHelper ?? throw new ArgumentNullException(nameof(fileServiceHelper));
|
||||
_coreApiClient = coreApiClient ?? throw new ArgumentNullException(nameof(coreApiClient));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveNaplozas(TanoraNaplozasRogzites model)
|
||||
{
|
||||
return base.SaveNaplozas(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveNemMegtartottNaplozas(TanoraNaplozasRogzites model)
|
||||
{
|
||||
return base.SaveNemMegtartottNaplozas(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public IHttpActionResult ValidateNaplozas(TanoraNaplozasRogzites model)
|
||||
{
|
||||
return base.ValidateNaplozas(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public IHttpActionResult UtkozesValidateNaplozas(TanoraIdBeallitasModel model)
|
||||
{
|
||||
model.calendarModel.Start = model.calendarModel.Start.ToLocalTime();
|
||||
var connectionType = ConnectionTypeExtensions.GetSessionConnectionType();
|
||||
var naploValidacioParameters = new NaploValidacioParameters(model.calendarModel.Start, connectionType, ClaimData.FelhasznaloSzerepkor);
|
||||
var validator = new NaploValidacio(naploValidacioParameters);
|
||||
|
||||
NaplozasElokeszitesLogic naplozasLogic;
|
||||
if (model.calendarModel.EventType == EventTypeEnum.UjEgyediOraFelvitel ||
|
||||
(model.calendarModel.EventType == EventTypeEnum.UjOraFelvitele && (model.calendarModel.OraType == CalendarOraTypeEnum.UresOra ||
|
||||
model.calendarModel.OraType == CalendarOraTypeEnum.Egyeb)))
|
||||
{
|
||||
var co = new EgyediNaplozasElokeszitesCo();
|
||||
model.ConvertTo(co);
|
||||
naplozasLogic = new NaplozasElokeszitesLogic(validator, co);
|
||||
}
|
||||
else
|
||||
{
|
||||
var co = new NaplozasElokeszitesCo();
|
||||
model.calendarModel.ConvertTo(co);
|
||||
naplozasLogic = new NaplozasElokeszitesLogic(validator, co);
|
||||
}
|
||||
|
||||
var systemSettingsHelper = new SystemSettingsHelper(connectionType);
|
||||
var tevekenysegUtkozes = systemSettingsHelper.GetSystemSettingValue<int>(RendszerBeallitasTipusEnum.Napirend_felvitelel_utkozes_figyeles);
|
||||
|
||||
var osztalyVagyTanarOraiadottUtkozes = TanevRendjeLogic.IsEgyediNapByDate(model.calendarModel.Start.Date) ? "" : naplozasLogic.GetOsztalyEsTanarOraiUtkozes();
|
||||
switch ((TevekenysegUtkozesEnum)tevekenysegUtkozes)
|
||||
{
|
||||
case TevekenysegUtkozesEnum.UtkozesNemLehetseges:
|
||||
if (!string.IsNullOrWhiteSpace(osztalyVagyTanarOraiadottUtkozes))
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, string.Format(OrarendResource.TanoraFelviteleNemLehetsegesUtkozesMiatt, osztalyVagyTanarOraiadottUtkozes));
|
||||
}
|
||||
break;
|
||||
case TevekenysegUtkozesEnum.UtkozeskorFigyelmeztetes:
|
||||
if (!string.IsNullOrWhiteSpace(osztalyVagyTanarOraiadottUtkozes))
|
||||
{
|
||||
return Json(new { Valid = false, Text = string.Format(OrarendResource.TanoraFelviteleNemLehetsegesUtkozesMiattKerdes, string.Empty, string.Empty, osztalyVagyTanarOraiadottUtkozes) });
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Json(new { Valid = true, Text = "" });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveNemKotottMunkaIdo(NemKotottMunkaidoModel model)
|
||||
{
|
||||
model.isMegtartott = true;
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
model.Kezdet = Logic.OrarendiOraLogic.CreateLocalDateTimeBasedOnDateAndTime(model.Datum.Value, model.Kezdet.Value);
|
||||
model.Veg = Logic.OrarendiOraLogic.CreateLocalDateTimeBasedOnDateAndTime(model.Datum.Value, model.Veg.Value);
|
||||
|
||||
var customModelState = Logic.NemKotottMunkaidoLogic.CheckCustomValidation(ModelState, model);
|
||||
if (!customModelState.IsValid)
|
||||
{
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, customModelState);
|
||||
}
|
||||
|
||||
NemKotottMunkaidoHelper helper = new NemKotottMunkaidoHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var co = Logic.NemKotottMunkaidoLogic.ConvertModelToCO(model);
|
||||
if (model.Id.IsEntityId())
|
||||
{
|
||||
helper.Update(co);
|
||||
}
|
||||
else
|
||||
{
|
||||
co.GroupId = Guid.NewGuid().ToString();
|
||||
helper.Insert(co);
|
||||
}
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (BlException ex)
|
||||
{
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteNemKotottMunkaIdo(int Id, bool isGlobal)
|
||||
{
|
||||
var authorization = (IKretaAuthorization)Request.GetDependencyScope().GetService(typeof(IKretaAuthorization));
|
||||
if (!authorization.IsValidNemKotottMunkaido(Id))
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.Forbidden, ErrorResource.AFelhasznalonakNincsMegfeleloJogosultsagaAFunkcioHasznalatahoz);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var helper = new NemKotottMunkaidoHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
LicenceHelper.LicenceWait(ClaimData.LicenceDatum);
|
||||
helper.Delete(Id, isAdmin: false, isGlobal);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (KretaError ke)
|
||||
{
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ke.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteTanarAltalNemKotottMunkaIdo(int Id)
|
||||
{
|
||||
var authorization = (IKretaAuthorization)Request.GetDependencyScope().GetService(typeof(IKretaAuthorization));
|
||||
if (!authorization.IsValidNemKotottMunkaido(Id))
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.Forbidden, ErrorResource.AFelhasznalonakNincsMegfeleloJogosultsagaAFunkcioHasznalatahoz);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var helper = new NemKotottMunkaidoHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
LicenceHelper.LicenceWait(ClaimData.LicenceDatum);
|
||||
helper.DeleteTanarAltal(Id);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (KretaError ke)
|
||||
{
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ke.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public IHttpActionResult UtkozesValidateNemKotottMunkaido(NemKotottMunkaidoModel model)
|
||||
{
|
||||
var hasUtkozes = Logic.NemKotottMunkaidoLogic.CheckUtkozesValidation(model);
|
||||
int tevekenysegutkozesSystemSetting = Logic.NemKotottMunkaidoLogic.GetTevekenysegUtkozesSystemSetting();
|
||||
|
||||
if (tevekenysegutkozesSystemSetting != (int)TevekenysegUtkozesEnum.UtkozesMegengedett && hasUtkozes)
|
||||
{
|
||||
if (tevekenysegutkozesSystemSetting == (int)TevekenysegUtkozesEnum.UtkozesNemLehetseges)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, OrarendResource.NemKotottMunkaidoFelviteleNemLehetsegesUtkozesMiatt);
|
||||
}
|
||||
|
||||
return Json(new { Valid = false, Text = string.Format(OrarendResource.NemKotottMunkaidoFelviteleNemLehetsegesUtkozesMiattKerdes) });
|
||||
}
|
||||
return Json(new { Valid = true, Text = string.Empty });
|
||||
}
|
||||
|
||||
public DataSourceResult GetMulasztasokForInfo(int osztalycsoportId, int tanoraId, DateTime oraKezdete, DateTime oraVege, int targyId, int tanarId, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
return new MulasztasLogic(ConnectionTypeExtensions.GetSessionConnectionType()).GetMulasztasok(osztalycsoportId, tanoraId, oraKezdete, oraVege, targyId, tanarId, false).ToDataSourceResult();
|
||||
}
|
||||
|
||||
public DataSourceResult GetMulasztasokForDetail(int osztalycsoportId, int tanoraId, DateTime oraKezdete, DateTime oraVege, int targyId, int tanarId, bool hianyzokAutoKitoltes, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
return new MulasztasLogic(ConnectionTypeExtensions.GetSessionConnectionType()).GetMulasztasok(osztalycsoportId, tanoraId, oraKezdete, oraVege, targyId, tanarId, hianyzokAutoKitoltes).ToDataSourceResult();
|
||||
}
|
||||
|
||||
public string GetTanarokNeve(string id)
|
||||
{
|
||||
return int.TryParse(id, out int fID) && fID.IsEntityId()
|
||||
? new FoglalkozasHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetTanarokTanoranKivuliFoglalkozashoz(fID)
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
public bool IsTanevRendEsemenyNemKotottMunkaido(CalendarModel model)
|
||||
{
|
||||
var helper = new TanevrendHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
return helper.GetVanTanevRendjeEsemenyNemKotottMunkaido(model.Start, model.End);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public DateTime GetNaplozarasDate(CalendarModel model)
|
||||
{
|
||||
var helper = new OrarendHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
return helper.GetNaplozarasDate(model.Start).ToUniversalTime();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public JObject GetNaploZarasInfo(CalendarModel model)
|
||||
{
|
||||
var naplozarasDate = GetNaplozarasDate(model);
|
||||
bool csakErtekelesZarasa = new NaplozarasLogic(ConnectionTypeExtensions.GetActiveSessionConnectionType()).IsCsakErtekelesZarasaBeallitas();
|
||||
JObject json = JObject.FromObject(new { NaplozarasDate = naplozarasDate, CsakErtekelesZarasa = csakErtekelesZarasa });
|
||||
return json;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public int GetCsengetesiRend(CalendarModel model)
|
||||
{
|
||||
var helper = new TanoraHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
return helper.GetTanitasiCsengetesiRendOraIdja(model.EventId);
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetHelyettesitesTipus(string osszevonas = null)
|
||||
{
|
||||
var data = FrameworkEnumExtensions.EnumToList((int)GeneratedAdatszotarTipusEnum.HelyettesitesTipus, ClaimData.SelectedTanevID.Value, false);
|
||||
|
||||
if (osszevonas != ((int)HelyettesitesTipusEnum.oraosszevonas).ToString())
|
||||
{
|
||||
data.Remove(((int)HelyettesitesTipusEnum.oraosszevonas).ToString());
|
||||
}
|
||||
|
||||
return Json(data.ToComboBoxItemList());
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetHelyettesitesTipusOsszevonassal()
|
||||
{
|
||||
var data = FrameworkEnumExtensions.EnumToList((int)GeneratedAdatszotarTipusEnum.HelyettesitesTipus, ClaimData.SelectedTanevID.Value, false);
|
||||
|
||||
return Json(data.ToComboBoxItemList());
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetHelyettesitoTanarok()
|
||||
{
|
||||
var helper = new TanarHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
var data = helper.GetTanarNevek(string.Empty, oktatasiAzonositoval: true);
|
||||
data.Remove(ClaimData.FelhasznaloId.ToString());
|
||||
|
||||
return Json(data.ToComboBoxItemList());
|
||||
}
|
||||
|
||||
public JsonResult<List<GroupComboBoxListItem>> GetTanoranKivuliFoglalkozasok(DateTime? datum = null, bool? isForOrarend = null, bool? filterNincsBeloleOra = false, int? hanyadikOra = null)
|
||||
{
|
||||
return GetTanoranKivuliFoglalkozasok(ClaimData.FelhasznaloId, filterNincsBeloleOra ?? false, datum, isForOrarend, hanyadikOra);
|
||||
}
|
||||
|
||||
public JsonResult<List<GroupComboBoxListItem>> GetTanoranKivuliFoglalkozasok(int filterId, bool filterNincsBeloleOra = false, DateTime? datum = null, bool? isForOrarend = null, int? hanyadikOra = null)
|
||||
{
|
||||
var connectionType = ConnectionTypeExtensions.GetSessionConnectionType();
|
||||
var helper = new TantargyFelosztasHelper(connectionType);
|
||||
|
||||
var foglalkozasok = helper.GetFoglalkozasok(filterId, filterNincsBeloleOra: filterNincsBeloleOra);
|
||||
var list = foglalkozasok.Tables[0].AsEnumerable();
|
||||
|
||||
if (isForOrarend.HasValue && isForOrarend.Value && datum.HasValue && hanyadikOra.HasValue)
|
||||
{
|
||||
var osztalyCsoportIds = new CsengetesiRendHelper(connectionType).GetOsztalyCsoportIdsForCsengetesiRend(datum.Value, hanyadikOra.Value, list.Select(x => x.Field<int>("OsztalyCsoportId")));
|
||||
|
||||
list = list.Where(x => osztalyCsoportIds.Contains(x.Field<int>("OsztalyCsoportId")));
|
||||
}
|
||||
|
||||
var filteredList = list.Select(dataRow => new ComboBoxListItem
|
||||
{
|
||||
Value = dataRow.Field<int>("ID").ToString() + " - " + dataRow.Field<int>("OsztalyCsoportId").ToString(),
|
||||
Text = dataRow.Field<string>("Tantargy") + " - " + dataRow.Field<string>("OsztalyCsoportNev"),
|
||||
GroupName = dataRow.Field<string>("IsOsztalyOrOsztalyJelleguCsoport") == "T" ? StringResourcesUtil.GetString(4808) /*Tanórai célú csoportok*/ : StringResourcesUtil.GetString(4809) /*Tanórán kívüli csoportok*/
|
||||
}).ToList();
|
||||
|
||||
return Json(ComboBoxHelper.ConvertDataToGroup(filteredList));
|
||||
}
|
||||
|
||||
public JsonResult<List<GroupComboBoxListItem>> GetNapirendTanoranKivuliFoglalkozasok(int filterId, DateTime? datum = null, bool? isForOrarend = null, int? hanyadikOra = null)
|
||||
{
|
||||
var connectionType = ConnectionTypeExtensions.GetSessionConnectionType();
|
||||
var helper = new TantargyFelosztasHelper(connectionType);
|
||||
|
||||
var foglalkozasok = helper.GetFoglalkozasok(filterId);
|
||||
var list = foglalkozasok.Tables[0].AsEnumerable();
|
||||
|
||||
if (isForOrarend.HasValue && isForOrarend.Value && datum.HasValue && hanyadikOra.HasValue)
|
||||
{
|
||||
var osztalyCsoportIds = new CsengetesiRendHelper(connectionType).GetOsztalyCsoportIdsForCsengetesiRend(datum.Value, hanyadikOra.Value, list.Select(x => x.Field<int>("OsztalyCsoportId")));
|
||||
|
||||
list = list.Where(x => osztalyCsoportIds.Contains(x.Field<int>("OsztalyCsoportId")));
|
||||
}
|
||||
|
||||
var systemSettingsHelper = new SystemSettingsHelper(connectionType);
|
||||
var csakOsztalyEsTanoraJelleguCsoport = systemSettingsHelper.GetSystemSettingValue<bool>(RendszerBeallitasTipusEnum.Foglalkozasnal_csak_osztaly_es_tanora_jellegu_csoport_allithato);
|
||||
|
||||
if (csakOsztalyEsTanoraJelleguCsoport)
|
||||
{
|
||||
list = list.Where(x => x.Field<string>("IsOsztalyOrOsztalyJelleguCsoport") == "T");
|
||||
}
|
||||
|
||||
var filteredList = list.Select(dataRow => new ComboBoxListItem
|
||||
{
|
||||
Value = dataRow.Field<int>("ID").ToString() + " - " + dataRow.Field<int>("OsztalyCsoportId").ToString(),
|
||||
Text = dataRow.Field<string>("Tantargy") + " - " + dataRow.Field<string>("OsztalyCsoportNev"),
|
||||
GroupName = dataRow.Field<string>("IsOsztalyOrOsztalyJelleguCsoport") == "T" ? StringResourcesUtil.GetString(4808) /*Tanórai célú csoportok*/ : StringResourcesUtil.GetString(4809) /*Tanórán kívüli csoportok*/
|
||||
}).ToList();
|
||||
|
||||
return Json(ComboBoxHelper.ConvertDataToGroup(filteredList));
|
||||
}
|
||||
|
||||
public JsonResult<List<GroupComboBoxListItem>> GetTanoranKivuliFoglalkozasokOsztalyList()
|
||||
{
|
||||
var systemSettingsHelper = new SystemSettingsHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
var csakOsztalyEsTanoraJelleguCsoport = systemSettingsHelper.GetSystemSettingValue<bool>(RendszerBeallitasTipusEnum.Foglalkozasnal_csak_osztaly_es_tanora_jellegu_csoport_allithato);
|
||||
|
||||
var ocsHelper = new OsztalyCsoportHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
var ds = ocsHelper.GetOsztalyCsoportokTanoranKivuliFoglalkozasokhozWithGroup(csakOsztalyEsTanoraJelleguCsoport);
|
||||
|
||||
var result = new List<ComboBoxListItem>();
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var item = new ComboBoxListItem();
|
||||
item.Value = dr["ID"].ToString();
|
||||
item.Text = dr["OsztalyCsoport"].ToString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(SDAConvert.ToString(dr["CsoportTipusa_DNAME"])))
|
||||
{
|
||||
item.GroupName = dr["CsoportTipusa_DNAME"].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.GroupName = "";
|
||||
}
|
||||
result.Add(item);
|
||||
}
|
||||
|
||||
return Json(ComboBoxHelper.ConvertDataToGroup(result));
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetTantargyak([DataSourceRequest] DataSourceRequest request, bool filterNincsBeloleOra = false)
|
||||
{
|
||||
var helper = new TantargyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
var dictionary = helper.GetTantargyakForDDL(filterNincsBeloleOra: filterNincsBeloleOra, isSzakkepzo: ClaimData.IsSzakkepzoIntezmeny);
|
||||
var dropdownListItems = new List<ComboBoxListItem>();
|
||||
|
||||
foreach (var item in dictionary)
|
||||
{
|
||||
var sli = new ComboBoxListItem() { Text = item.Value, Value = item.Key };
|
||||
dropdownListItems.Add(sli);
|
||||
}
|
||||
return Json(dropdownListItems);
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetErtekelesTipus()
|
||||
{
|
||||
return Json(FrameworkEnumExtensions.EnumToList((int)GeneratedAdatszotarTipusEnum.ErtekelesMod, ClaimData.SelectedTanevID.Value, true).ToComboBoxItemList());
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetTema(int osztcsop, int targy)
|
||||
{
|
||||
var helper = new TanoraHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
var list = helper.GetTemaIdAndNameForNaplozasDDL(targy, osztcsop).ToComboBoxItemList();
|
||||
|
||||
return Json(list);
|
||||
}
|
||||
|
||||
public JsonResult<DataTable> CheckTanarOra(CalendarModel model)
|
||||
{
|
||||
var helper = new OrarendHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var data = helper.CheckTanarOra(model.Start, model.End, model.HelyettesitoId.Value, model.Hanyadikora, isNapirend: false, isEgyediHelyettesites: false);
|
||||
return Json(data.Tables[0]);
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Naplo.ClaimValue, KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public JsonResult<List<ComboBoxListItem>> GetTorvenyKategoriaList()
|
||||
{
|
||||
var dictionary = FrameworkEnumExtensions.EnumToList((int)GeneratedAdatszotarTipusEnum.TevekenysegTipus, ClaimData.SelectedTanevID.Value);
|
||||
List<ComboBoxListItem> list = new List<ComboBoxListItem>();
|
||||
|
||||
foreach (var item in dictionary)
|
||||
{
|
||||
ComboBoxListItem ci = new ComboBoxListItem() { Text = item.Value, Value = item.Key };
|
||||
list.Add(ci);
|
||||
}
|
||||
|
||||
return Json(list);
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetTanarList()
|
||||
{
|
||||
return Json(GetTanarDictionary().ToComboBoxItemList());
|
||||
}
|
||||
|
||||
public List<System.Web.Mvc.SelectListItem> GetTanarListItems()
|
||||
{
|
||||
return GetTanarDictionary().ToSelectListItemList();
|
||||
}
|
||||
|
||||
private static IDictionary<string, string> GetTanarDictionary()
|
||||
{
|
||||
IDictionary<string, string> list;
|
||||
var helper = new TanarHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
list = helper.GetTanarok(string.Empty, oktatasiAzonositoval: false);
|
||||
|
||||
list.Remove("");
|
||||
return list;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public IHttpActionResult DeleteTanora(TanoraMuveletek pram)
|
||||
{
|
||||
return base.DeleteTanora(pram);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
/// TODO: (DevKornél) string resx-ből
|
||||
/// TODO: (DevKornél) pram rename
|
||||
public IHttpActionResult OraOsszevonasDelete(TanoraMuveletek pram)
|
||||
{
|
||||
try
|
||||
{
|
||||
LicenceHelper.LicenceWait(ClaimData.LicenceDatum);
|
||||
var helper = new TanoraHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
helper.NaplozasTorlese(pram.CalendarModel.EventId);
|
||||
|
||||
return Json(new { Title = StringResourcesUtil.GetString(366) /*Siker*/, Text = StringResourcesUtil.GetString(3211) /*Sikeres törlés*/});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.InternalServerError, StringResourcesUtil.GetString(3212) /*Törlés sikertelen*/)
|
||||
{
|
||||
UnHandledException = ex
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public bool IsTanitasiNap(DateTime date)
|
||||
{
|
||||
var tanevrendHelper = new TanevrendHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
var isTanitasiNap = tanevrendHelper.IsTanitasiNap(date, null);
|
||||
|
||||
return isTanitasiNap;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public int GetOsztalyCsoportTerem(int? osztalyCsoportId)
|
||||
{
|
||||
if (osztalyCsoportId > 0)
|
||||
{
|
||||
return new OsztalyCsoportHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetOsztalyCsoportTeremId(osztalyCsoportId.Value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public int GetTeremByFoglalkozas(int? foglalkozasId)
|
||||
{
|
||||
if (foglalkozasId > 0)
|
||||
{
|
||||
var helper = new TantargyFelosztasHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
return helper.GetTeremByFoglalkozas(foglalkozasId.Value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public bool IsOrarendiNap(DateTime date)
|
||||
{
|
||||
var tanevrendHelper = new TanevrendHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
var isOrarendiNap = tanevrendHelper.IsOrarendiNap(date, null);
|
||||
|
||||
return isOrarendiNap;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public bool EnabledNemKotottMunkaidoRogzitese(DateTime date)
|
||||
{
|
||||
var tanevrendHelper = new TanevrendHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
var enabledNemKotottMunkaidoRogzitese = tanevrendHelper.EnabledNemKotottMunkaidoRogzitese(date);
|
||||
|
||||
return enabledNemKotottMunkaidoRogzitese;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveHaziFeladat(TanoraNaplozasRogzites model)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(model.HaziFeladatNaplozasRogzites.HaziFeladat) && !model.HaziFeladatNaplozasRogzites.Hatarido.HasValue && model.HaziFeladatNaplozasRogzites.Id.HasValue)
|
||||
{
|
||||
new DktFeladatHelper(ConnectionTypeExtensions.GetSessionConnectionType()).DeleteHazi(model.HaziFeladatNaplozasRogzites.Id.Value, _coreApiClient);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(model.HaziFeladatNaplozasRogzites.HaziFeladat))
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, OrarendResource.AHaziFeladatSzovegeNemLehetUres);
|
||||
}
|
||||
if (!model.HaziFeladatNaplozasRogzites.Hatarido.HasValue)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, OrarendResource.HataridoMegadasaKotelezo);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var orarendiOra = new OrarendiOraHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetOrarendiOraById(model.TanoraMuveletek.CalendarModel.EventId);
|
||||
var co = new BusinessLogic.HelperClasses.TanarHaziFeladatCO
|
||||
{
|
||||
Id = model.HaziFeladatNaplozasRogzites.Id,
|
||||
Szoveg = CommonUtils.CreateLinksInText(model.HaziFeladatNaplozasRogzites.HaziFeladat),
|
||||
TanitasiOraId = null,
|
||||
TantargyId = orarendiOra.TantargyId,
|
||||
FeladasDatuma = model.TanoraMuveletek.CalendarModel.Start.Date,
|
||||
Hatarido = model.HaziFeladatNaplozasRogzites.Hatarido.Value,
|
||||
HelyettesitoId = model.TanoraMuveletek.CalendarModel.HelyettesitoId,
|
||||
IsTanarRogzitette = true,
|
||||
OrarendiOraId = model.TanoraMuveletek.CalendarModel.EventId,
|
||||
Oraszam = model.TanoraMuveletek.CalendarModel.Hanyadikora,
|
||||
Idopont = model.TanoraAdatokRogzites.OraKezdete,
|
||||
OsztalyCsoportId = orarendiOra.OsztalyCsoportId,
|
||||
RogzitoId = ClaimData.FelhasznaloId,
|
||||
IntezmenyId = ClaimData.IntezmenyId,
|
||||
IntezmenyAzonosito = ClaimData.IntezmenyAzonosito,
|
||||
TanevId = ClaimData.SelectedTanevID.Value,
|
||||
CsatolmanyId = model.HaziFeladatNaplozasRogzites.CsatolmanyId
|
||||
};
|
||||
var hfId = new DktFeladatHelper(ConnectionTypeExtensions.GetSessionConnectionType()).SaveOrUpdateTanarHaziFeladat(co, orarendiOra.TanarId, _fileServiceHelper, _coreApiClient);
|
||||
return Request.CreateResponse(HttpStatusCode.OK, new { HazifeladatId = hfId });
|
||||
}
|
||||
catch { throw; }
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveHaziFeladatFromDetail(HaziFeladatNaplozas model)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(model.HaziFeladat) && !model.Hatarido.HasValue && model.Id.HasValue)
|
||||
{
|
||||
new DktFeladatHelper(ConnectionTypeExtensions.GetSessionConnectionType()).DeleteHazi(model.Id.Value, _coreApiClient);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(model.HaziFeladat))
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, OrarendResource.AHaziFeladatSzovegeNemLehetUres);
|
||||
}
|
||||
if (!model.Hatarido.HasValue)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, OrarendResource.HataridoMegadasaKotelezo);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BusinessLogic.HelperClasses.TanarHaziFeladatCO co;
|
||||
int? tanarId;
|
||||
if (!model.IsElmaradt)
|
||||
{
|
||||
var orarendiOra = new OrarendiOraHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetOrarendiOraById(model.OrarendiOraId.Value);
|
||||
tanarId = orarendiOra.TanarId;
|
||||
co = new BusinessLogic.HelperClasses.TanarHaziFeladatCO
|
||||
{
|
||||
Id = model.Id,
|
||||
Szoveg = CommonUtils.CreateLinksInText(model.HaziFeladat),
|
||||
TanitasiOraId = null,
|
||||
TantargyId = orarendiOra.TantargyId,
|
||||
FeladasDatuma = model.NapDatuma.Value,
|
||||
Hatarido = model.Hatarido.Value,
|
||||
HelyettesitoId = null,
|
||||
IsTanarRogzitette = true,
|
||||
OrarendiOraId = model.OrarendiOraId,
|
||||
Oraszam = orarendiOra.Oraszam,
|
||||
Idopont = orarendiOra.OraKezdete,
|
||||
OsztalyCsoportId = orarendiOra.OsztalyCsoportId,
|
||||
RogzitoId = ClaimData.FelhasznaloId,
|
||||
IntezmenyId = ClaimData.IntezmenyId,
|
||||
IntezmenyAzonosito = ClaimData.IntezmenyAzonosito,
|
||||
TanevId = ClaimData.SelectedTanevID.Value,
|
||||
CsatolmanyId = model.CsatolmanyId
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var tanora = new TanoraHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetTanorakAdatok(model.TanitasiOraId.Value);
|
||||
tanarId = tanora.Tanar;
|
||||
co = new BusinessLogic.HelperClasses.TanarHaziFeladatCO
|
||||
{
|
||||
Id = model.Id,
|
||||
Szoveg = CommonUtils.CreateLinksInText(model.HaziFeladat),
|
||||
TanitasiOraId = model.TanitasiOraId,
|
||||
TantargyId = tanora.Targy,
|
||||
FeladasDatuma = model.NapDatuma.Value,
|
||||
Hatarido = model.Hatarido.Value,
|
||||
HelyettesitoId = null,
|
||||
IsTanarRogzitette = true,
|
||||
OrarendiOraId = null,
|
||||
Idopont = tanora.OraKezd,
|
||||
OsztalyCsoportId = tanora.OsztCsop,
|
||||
RogzitoId = ClaimData.FelhasznaloId,
|
||||
IntezmenyId = ClaimData.IntezmenyId,
|
||||
IntezmenyAzonosito = ClaimData.IntezmenyAzonosito,
|
||||
TanevId = ClaimData.SelectedTanevID.Value,
|
||||
CsatolmanyId = model.CsatolmanyId
|
||||
};
|
||||
}
|
||||
|
||||
var hfId = new DktFeladatHelper(ConnectionTypeExtensions.GetSessionConnectionType()).SaveOrUpdateTanarHaziFeladat(co, tanarId, _fileServiceHelper, _coreApiClient);
|
||||
return Request.CreateResponse(HttpStatusCode.OK, new { HazifeladatId = hfId });
|
||||
}
|
||||
catch (BlException ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ex.Message);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public JsonResult<CheckFoglalkozasRogzithetoResult> CheckFoglalkozasRogzitheto(DateTime calendarStartDate)
|
||||
{
|
||||
var localCalendarstartDate = calendarStartDate.ToLocalTime();
|
||||
var orarendHelper = new OrarendHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
var tanevrendHelper = new TanevrendHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var isOrarendiNap = tanevrendHelper.IsOrarendiNap(localCalendarstartDate, osztalycsoportId: null);
|
||||
var isTanitasiNap = tanevrendHelper.IsTanitasiNap(localCalendarstartDate, osztalycsoportId: null);
|
||||
|
||||
var naplozaras = orarendHelper.GetNaplozarasDate(localCalendarstartDate);
|
||||
var isCsakErtekelesZarasa = new NaplozarasLogic(ConnectionTypeExtensions.GetSessionConnectionType()).IsCsakErtekelesZarasaBeallitas();
|
||||
var isNaplozaras = naplozaras >= localCalendarstartDate;
|
||||
|
||||
var isNapirendMegnyithato = IsNapirendMegnyithato();
|
||||
|
||||
var result = new CheckFoglalkozasRogzithetoResult
|
||||
{
|
||||
IsOrarendiNap = isOrarendiNap,
|
||||
IsTanitasiNap = isTanitasiNap,
|
||||
IsNaplozaras = isNaplozaras,
|
||||
IsCsakErtekelesZarasa = isCsakErtekelesZarasa,
|
||||
IsNapirendMegnyithato = isNapirendMegnyithato
|
||||
};
|
||||
return Json(result);
|
||||
}
|
||||
|
||||
private bool IsNapirendMegnyithato()
|
||||
{
|
||||
var systemSettingsHelper = new SystemSettingsHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
return !systemSettingsHelper.GetSystemSettingValue<bool>(RendszerBeallitasTipusEnum.Pedagogusok_csak_az_eloirt_helyettesiteseiket_regisztralhatjak_a_haladasi_naploban) ||
|
||||
systemSettingsHelper.GetSystemSettingValue<bool>(RendszerBeallitasTipusEnum.Tanar_vehet_e_fel_orat_maganak) ||
|
||||
systemSettingsHelper.GetSystemSettingValue<bool>(RendszerBeallitasTipusEnum.Lehet_orat_felvenni_TTF_nelkul);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult<OraCO> GetCsengetesiRendEsOrak(CsengetesiRendOraszamaModel csengetesiRend)
|
||||
{
|
||||
var helper = new CsengetesiRendHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var data = helper.GetCsengetesiRendEsOrak(csengetesiRend.AktualisCsengetesiRendId, csengetesiRend.AktualisOraSzam).Tables[0].Rows;
|
||||
|
||||
var ora = new OraCO
|
||||
{
|
||||
Kezdete = data.Count > 0 ? data[0].Field<DateTime>("Kezdete").TimeOfDay : TimeSpan.Zero,
|
||||
Vege = data.Count > 0 ? data[0].Field<DateTime>("Vege").TimeOfDay : TimeSpan.Zero
|
||||
};
|
||||
|
||||
return Json(ora);
|
||||
}
|
||||
|
||||
public bool IsHelyettesitesTulora(KeziHelyettesitesIsTuloraModel cm)
|
||||
{
|
||||
var helper = new OrarendHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
var ds = helper.CheckTanarOra(SDAConvert.ToDateTime(cm.Start).Value, SDAConvert.ToDateTime(cm.End).Value, SDAConvert.ToInt32(cm.HelyettesitettId), SDAConvert.ToNullableInt32(cm.Hanyadikora), SDAConvert.ToBoolean(cm.UseFoglakozas), true);
|
||||
|
||||
if (ds != null && ds.Tables.Count > 0)
|
||||
{
|
||||
var szuksegesSorok = ds.Tables[0].AsEnumerable().ToList();
|
||||
if (szuksegesSorok.Count == 1 && szuksegesSorok[0].Field<string>("C_TULORA") == "T")
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public class KeziHelyettesitesIsTuloraModel
|
||||
{
|
||||
public int HelyettesitettId { get; set; }
|
||||
public DateTime Start { get; set; }
|
||||
public DateTime End { get; set; }
|
||||
public int Hanyadikora { get; set; }
|
||||
public bool UseFoglakozas { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue