153 lines
6 KiB
C#
153 lines
6 KiB
C#
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.Interfaces;
|
|
using Kreta.BusinessLogic.Logic.Mulasztas;
|
|
using Kreta.BusinessLogic.Security;
|
|
using Kreta.BusinessLogic.Utils;
|
|
using Kreta.Client.CoreApi;
|
|
using Kreta.Core.Exceptions;
|
|
using Kreta.Enums;
|
|
using Kreta.Framework;
|
|
using Kreta.Framework.Util;
|
|
using Kreta.Web.Helpers;
|
|
using Kreta.Web.Helpers.Error;
|
|
using Kreta.Web.Helpers.Grid;
|
|
using Kreta.Web.Security;
|
|
|
|
namespace Kreta.Web.Areas.Orarend.ApiControllers
|
|
{
|
|
[ApiRoleClaimsAuthorize(true)]
|
|
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
|
public class AdminNaploEllenorzesApiController : ApiController
|
|
{
|
|
private readonly IFileServiceHelper fileServiceHelper;
|
|
private readonly ICoreApiClient coreApiClient;
|
|
|
|
public AdminNaploEllenorzesApiController(IFileServiceHelper fileServiceHelper, ICoreApiClient coreApiClient)
|
|
{
|
|
this.fileServiceHelper = fileServiceHelper ?? throw new ArgumentNullException(nameof(fileServiceHelper));
|
|
this.coreApiClient = coreApiClient ?? throw new ArgumentNullException(nameof(coreApiClient));
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage UpdateNemMegtartott(int id, DateTime oraKezdete, DateTime oraVege)
|
|
{
|
|
var helper = new OrarendiOraHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
var helperCo = helper.GetOrarendiOraById(id);
|
|
|
|
var co = new TanoraCO();
|
|
co.Targy = helperCo.TantargyId;
|
|
co.Terem = helperCo.TeremID;
|
|
co.IsTanoranKivuli = helperCo.TanoranKivuliFoglalkozas;
|
|
co.Sorszamozando = false;
|
|
co.OrarendiOra = helperCo.ID;
|
|
co.OsztCsop = helperCo.OsztalyCsoportId;
|
|
co.Tanar = helperCo.TanarId;
|
|
co.OraKezd = oraKezdete;
|
|
co.OraVeg = oraVege;
|
|
co.Oraszam = helperCo.Oraszam;
|
|
co.EvesOraSorszam = null;
|
|
co.Megtartott = false;
|
|
co.Tulaj = helperCo.TanarId;
|
|
co.HetNapja = helperCo.HetNapja;
|
|
co.CsengetesiRendID = helperCo.CsengetesiRendID;
|
|
co.AdminAltalKiirt = true;
|
|
co.Datum = co.OraKezd.Date;
|
|
|
|
var thelper = new TanoraHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
thelper.TanoraNaplozas(co, mulasztasCo: null, fileServiceHelper, coreApiClient);
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ApiValidateAjaxAntiForgeryToken]
|
|
public HttpResponseMessage DeleteNaplozas(int id)
|
|
{
|
|
try
|
|
{
|
|
var helper = new TanoraHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
|
|
|
helper.NaplozasTorlese(id, true);
|
|
|
|
}
|
|
catch (BlException e)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, e.Message) { UnHandledException = e };
|
|
}
|
|
|
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
|
}
|
|
|
|
public DataSourceResult GetMulasztasok(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();
|
|
}
|
|
|
|
private void SetMagantanuloFelmentett(DataSet ds)
|
|
{
|
|
foreach (DataRow item in ds.Tables[0].Rows)
|
|
{
|
|
if (SDAConvert.ToBoolean(item["IsMagantanulo_BOOL"]))
|
|
{
|
|
item["OraMentesseg"] = "T";
|
|
item["OraMentesseg_BOOL"] = true;
|
|
item["Oka"] = StringResourcesUtil.GetString(387); /*Magántanuló*/
|
|
}
|
|
}
|
|
}
|
|
|
|
public JsonResult<List<ComboBoxListItem>> GetTanarList()
|
|
{
|
|
var connectionType = ConnectionTypeExtensions.GetSessionConnectionType();
|
|
var felhasznalokOnlyAlkalmazottSzerepkorIds = new FelhasznaloHelper(connectionType).GetFelhasznaloIdsOnlyAlkalmazottSzerepkor();
|
|
IDictionary<string, string> lista;
|
|
var helper = new TanarHelper(connectionType);
|
|
lista = helper.GetTanarok(string.Empty, oktatasiAzonositoval: true);
|
|
|
|
lista.Remove("");
|
|
|
|
return Json(lista.ToComboBoxItemList().Where(x => !felhasznalokOnlyAlkalmazottSzerepkorIds.Contains(SDAConvert.ToInt32(x.Value))).ToList());
|
|
}
|
|
|
|
public JsonResult<List<ComboBoxListItem>> GetHelyettesitesTipus()
|
|
{
|
|
var data = FrameworkEnumExtensions.EnumToList((int)GeneratedAdatszotarTipusEnum.HelyettesitesTipus, ClaimData.SelectedTanevID.Value, false);
|
|
|
|
return Json(data.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 List<System.Web.Mvc.SelectListItem> GetTanarListItems()
|
|
{
|
|
IDictionary<string, string> list;
|
|
var helper = new TanarHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
list = helper.GetTanarok(string.Empty, oktatasiAzonositoval: false);
|
|
|
|
list.Remove("");
|
|
|
|
return list.ToSelectListItemList();
|
|
}
|
|
}
|
|
}
|