kreta/KretaWeb/Areas/Adminisztracio/ApiControllers/AktivTanevValtasaApiController.cs
2024-03-13 00:33:46 +01:00

77 lines
3.3 KiB
C#

using System.Collections.Generic;
using System.Data;
using System.Web.Http;
using System.Web.Http.ModelBinding;
using Kendo.Mvc.UI;
using Kreta.BusinessLogic.Classes;
using Kreta.BusinessLogic.Helpers;
using Kreta.BusinessLogic.Security;
using Kreta.Enums.ManualEnums;
using Kreta.Web.Areas.Adminisztracio.Models;
using Kreta.Web.Helpers;
using Kreta.Web.Helpers.Grid;
using Kreta.Web.Security;
namespace Kreta.Web.Areas.Adminisztracio.ApiControllers
{
[ApiRoleClaimsAuthorize(true)]
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
public class AktivTanevValtasaApiController : ApiController
{
public AktivTanevValtasaModel GetAktivTanevValtasaModel()
{
DataSet ds;
DataSet dsAlkalmazottak;
var helper = new AdminHelper(!ClaimData.SelectedTanevID.HasValue ? ConnectionTypeExtensions.GetActiveSessionConnectionType() : ConnectionTypeExtensions.GetSessionConnectionType());
ds = helper.GetAktivTanevValtasaModel(ClaimData.KovTanevID.Value);
dsAlkalmazottak = helper.GetAlkalmazottakAlapErtekekkel(ClaimData.IsSelectedTanev20_21OrLater && ClaimData.IsSzakkepzoIntezmeny);
return ConvertDataSetToModel(ds, dsAlkalmazottak);
}
public DataSourceResult GetAlkalmazottTorlesGrid([ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
{
var thelper = new AlkalmazottHelper(ConnectionTypeExtensions.GetNextSessionConnectionType());
thelper.GridParameters = Converter.GridParameter(request);
var termek = thelper.TanevValtasAlkalmazottTorlesKereses();
return termek.ToDataSourceResult();
}
#region Helpers
public AktivTanevValtasaModel ConvertDataSetToModel(DataSet ds, DataSet dsAlkalmazottak)
{
var model = new AktivTanevValtasaModel();
if (ds.Tables[0].Rows.Count > 0)
{
DataRow dr = ds.Tables[0].Rows[0];
model.KiNemSoroltTanulokOsztaly = SDAConvert.ToInt32(dr["KiNemSoroltTanulokOsztaly"]);
model.KiNemSoroltTanulokCsoport = SDAConvert.ToInt32(dr["KiNemSoroltTanulokCsoport"]);
model.BeNemSoroltNebulok = SDAConvert.ToInt32(dr["BeNemSoroltNebulok"]);
model.VanTorlendoAlkalmazott = SDAConvert.ToInt32(dr["VanTorlendoAlkalmazott"]);
model.NemErtekeltOsszefuggoSzakmaiGyakorlatosTanulok = SDAConvert.ToInt32(dr["NemErtekeltOsszefuggoSzakmaiGyakorlatosTanulok"]);
}
model.AlkalmazottakAlapertekekkel = new List<string>();
if (dsAlkalmazottak != null && dsAlkalmazottak.Tables != null && dsAlkalmazottak.Tables.Count > 0 && dsAlkalmazottak.Tables[0].Rows.Count > 0)
{
foreach (DataRow item in dsAlkalmazottak.Tables[0].Rows)
{
model.AlkalmazottakAlapertekekkel.Add(SDAConvert.ToString(item["AlkalmazottNev"]));
}
}
LicenceTipusaEnum licence = LicenceHelper.LicenceLejaratAllapota(ClaimData.LicenceDatum);
if (licence == LicenceTipusaEnum.NegyedEveLejart || licence == LicenceTipusaEnum.EgyEveLejart)
model.LejartLicence = true;
else
model.LejartLicence = false;
return model;
}
#endregion
}
}