init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,180 @@
|
|||
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.Results;
|
||||
using System.Web.Mvc;
|
||||
using Kendo.Mvc.UI;
|
||||
using Kreta.BusinessLogic.Classes.ComboBox;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Tantargy.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.Tantargy.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Tanar.ClaimValue)]
|
||||
public class BaseTanmenetApiController : ApiController
|
||||
{
|
||||
public DataSourceResult GetTanmenetGrid(string data, [System.Web.Http.ModelBinding.ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var model = JsonConvert.DeserializeObject<TanmenetSearchModel>(data);
|
||||
model.FeltoltoIdSearch = ClaimData.FelhasznaloId;
|
||||
var thelper = new TanmenetHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
thelper.GridParameters = Converter.GridParameter(request);
|
||||
|
||||
TanmenetKereseseCO co = ConvertSearchModelToCo(model);
|
||||
DataSet tanmenetek = thelper.GetTanmenetek(co);
|
||||
return tanmenetek.ToDataSourceResult();
|
||||
|
||||
}
|
||||
|
||||
public string GetTanmenetModalHeader(int tantargyId, int osztalyId)
|
||||
{
|
||||
Enum.TryParse(new OsztalyCsoportHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).GetOsztalyCsoportFeladatKategoria(osztalyId).ToString(), out OktNevelesiKategoriaEnum kategoria);
|
||||
|
||||
return new TanmenetHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).GetTanmenetModalHeader(ClaimData.FelhasznaloId, tantargyId, osztalyId, kategoria);
|
||||
}
|
||||
|
||||
public DataSourceResult GetTanmenetOrak(int foglalkozasId, int TantargyId, int OsztalyId, [System.Web.Http.ModelBinding.ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var thelper = new TanmenetHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
thelper.GridParameters = Converter.GridParameter(request);
|
||||
DataSet tanmenetek = thelper.GetTanmenetek(TantargyId, OsztalyId, ClaimData.FelhasznaloId, foglalkozasId: foglalkozasId);
|
||||
return tanmenetek.ToDataSourceResult();
|
||||
}
|
||||
|
||||
[System.Web.Http.HttpPost]
|
||||
public HttpResponseMessage SaveTanmenet(TanmenetModel model)
|
||||
{
|
||||
if (model.TanmenetBejegyzesek.All(x => string.IsNullOrWhiteSpace(x.Tema)))
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.UresTanmenetetNemLehetMenteni);
|
||||
}
|
||||
|
||||
var temaLengthErrors = new List<string>();
|
||||
foreach (var bejegyzes in model.TanmenetBejegyzesek.Where(b => !string.IsNullOrWhiteSpace(b.Tema)))
|
||||
{
|
||||
// NOTE: bejegyzés név = "{oraszam}. {tema}", max 1000 karakter, amiből óraszám max 3 karakter lehet
|
||||
if (bejegyzes.Tema.Length > 995)
|
||||
{
|
||||
temaLengthErrors.Add(string.Format(ErrorResource.TanmenetBejegyzesTemaMaxKarakter, bejegyzes.Oraszam));
|
||||
}
|
||||
}
|
||||
|
||||
if (temaLengthErrors.Any())
|
||||
{
|
||||
var errorMsg = string.Join(Core.Constants.General.Sortores, temaLengthErrors);
|
||||
throw new StatusError(HttpStatusCode.BadRequest, errorMsg);
|
||||
}
|
||||
|
||||
model.AlkalmazottId = ClaimData.FelhasznaloId;
|
||||
TanmenetCO co = ConvertModelToCo(model);
|
||||
|
||||
var tHelper = new TanmenetHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
tHelper.SaveTanmenet(co);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
[System.Web.Http.HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage Delete([FromBody] int foglalkozasId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var helper = new TanmenetHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
List<TanmenetItemCo> tanmenetCoList = helper.GetTanmenetCoList(ClaimData.FelhasznaloId).Where(x => x.TantargyfelosztasId == foglalkozasId).ToList();
|
||||
foreach (TanmenetItemCo tanmenetCo in tanmenetCoList)
|
||||
{
|
||||
helper.DeleteTanmenet(tanmenetCo.Id);
|
||||
}
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.InternalServerError, ErrorResource.HibaATorlesSoran)
|
||||
{
|
||||
UnHandledException = e
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public List<SelectListItem> GetTantargyList()
|
||||
{
|
||||
List<SelectListItem> list = new List<SelectListItem>();
|
||||
TantargyHelper helper = new TantargyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
foreach (var item in helper.GetTantargyakForDDL(ClaimData.FelhasznaloId, isSzakkepzo: ClaimData.IsSzakkepzoIntezmeny))
|
||||
{
|
||||
SelectListItem sli = new SelectListItem() { Text = item.Value, Value = item.Key };
|
||||
list.Add(sli);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private TanmenetKereseseCO ConvertSearchModelToCo(TanmenetSearchModel model)
|
||||
{
|
||||
TanmenetKereseseCO co = new TanmenetKereseseCO()
|
||||
{
|
||||
AlkalmazottID = model.FeltoltoIdSearch,
|
||||
Megjegyzes = model.MegjegyzesSearch,
|
||||
Nev = model.NevSearch,
|
||||
Oraszam = model.OraszamSearch,
|
||||
OsztalyID = model.OsztalyCsoportIdSearch,
|
||||
RovidNev = model.RovidNevSearch,
|
||||
TantargyID = model.TantargyIdSearch,
|
||||
Tema = model.TemaSearch
|
||||
};
|
||||
return co;
|
||||
}
|
||||
|
||||
private TanmenetCO ConvertModelToCo(TanmenetModel model)
|
||||
{
|
||||
TanmenetCO co = new TanmenetCO()
|
||||
{
|
||||
AlkalmazottID = model.AlkalmazottId,
|
||||
FoglalkozasID = model.FoglalkozasId,
|
||||
Orak = new List<TanmenetOrakCO>()
|
||||
};
|
||||
|
||||
foreach (var tema in model.TanmenetBejegyzesek)
|
||||
{
|
||||
co.Orak.Add(new TanmenetOrakCO()
|
||||
{
|
||||
ID = string.IsNullOrWhiteSpace(tema.ID) ? new int?() : int.Parse(tema.ID),
|
||||
Tema = tema.Tema,
|
||||
Oraszam = tema.Oraszam
|
||||
}
|
||||
);
|
||||
}
|
||||
return co;
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetFoglalkozasList()
|
||||
{
|
||||
var helper = new TantargyFelosztasHelper(ConnectionTypeExtensions.GetSessionConnectionType())
|
||||
{
|
||||
GridParameters = null,
|
||||
};
|
||||
|
||||
var foglalkozasok = helper.GetTantargyFelosztasForDDL(ClaimData.FelhasznaloId);
|
||||
|
||||
return Json(foglalkozasok.ToComboBoxItemList());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,461 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.ModelBinding;
|
||||
using System.Web.Http.Results;
|
||||
using Kendo.Mvc.Extensions;
|
||||
using Kendo.Mvc.UI;
|
||||
using Kreta.BusinessLogic.Classes.ComboBox;
|
||||
using Kreta.BusinessLogic.Exceptions;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Logic;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.Exceptions;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Framework.Entities;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Tantargy.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.Tantargy.ApiControllers
|
||||
{
|
||||
public class BaseTantargyFelosztasApiController : ApiController
|
||||
{
|
||||
public DataSourceResult GetTantargyFelosztasok(string data, DataSourceRequest request)
|
||||
{
|
||||
var (gridParameter, modelList, _) = GetGridData(data, request);
|
||||
|
||||
var ret = modelList.ToDataSourceResult(gridParameter);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public HttpResponseMessage GetExport(string data, DataSourceRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var (gridParameter, modelList, exportAttributeName) = GetGridData(data, request);
|
||||
|
||||
modelList = modelList.SortingAndPaging(gridParameter.OrderDictionary);
|
||||
|
||||
var simpleExportColumnCos = SimpleExportLogic.GetSimpleExportColumnCos<TantargyFelosztasGridModel>(exportAttributeName);
|
||||
|
||||
var memoryStream = SimpleExportLogic.GetExport(TantargyfelosztasResource.ExportSheetName, simpleExportColumnCos, modelList, ClaimData.SelectedTanevID.Value);
|
||||
|
||||
return HttpResponseExtensions.GetFileHttpResponse(memoryStream.ToArray(), string.Format(TantargyfelosztasResource.ExportFileNameFormat, ClaimData.IntezmenyAzonosito));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAFajlExportalasaKozben) { UnHandledException = ex };
|
||||
}
|
||||
}
|
||||
|
||||
private (GridParameters gridParameter, List<TantargyFelosztasGridModel> modelList, string exportAttributeName) GetGridData(string data, DataSourceRequest request)
|
||||
{
|
||||
var connection = ConnectionTypeExtensions.GetSessionConnectionType();
|
||||
var model = JsonConvert.DeserializeObject<TantargyFelosztasModel>(data);
|
||||
var gridParameter = Converter.GridParameter(request);
|
||||
|
||||
var keresesModel = model.ConvertToCo();
|
||||
if (model.IsFromSzervezet)
|
||||
{
|
||||
var szervezetId = new SzervezetHelper(connection).GetAlkalmazottSzervezetId(ClaimData.FelhasznaloId);
|
||||
keresesModel.SzervezetId = szervezetId;
|
||||
}
|
||||
|
||||
var coList = new TantargyFelosztasHelper(connection).GetTantargyFelosztasCoList(keresesModel);
|
||||
|
||||
var modelList = new List<TantargyFelosztasGridModel>();
|
||||
foreach (var co in coList)
|
||||
{
|
||||
var gridModel = new TantargyFelosztasGridModel(co);
|
||||
modelList.Add(gridModel);
|
||||
}
|
||||
|
||||
var exportAttributeName = model.IsFromSzervezet ? TantargyFelosztasGridModel.DualisTantargyFelosztasExportAttributeId : TantargyFelosztasGridModel.TantargyFelosztasExportAttributeId;
|
||||
|
||||
return (gridParameter, modelList, exportAttributeName);
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue, KretaClaimPackages.Dualis_Admin.ClaimValue, KretaClaimPackages.IsSzakiranyuOktatasertFelelos.ClaimValue)]
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public void StoreSelectedTanar([FromBody] int tanarID)
|
||||
{
|
||||
if (tanarID > 0)
|
||||
{
|
||||
HttpContext.Current.Application["tanarId"] = tanarID;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult<bool> ValidateTantargyFelosztasModify(TantargyFelosztasModositasaModel model)
|
||||
{
|
||||
var helper = new TantargyFelosztasHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var result = helper.DuplicatedTantargyfelosztas(model.TanarId, model.CsoportID, model.TantargyId, model.Id);
|
||||
return Json(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveFelosztas(SaveFelosztasModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var helper = new TantargyFelosztasHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
foreach (var item in model.felosztasok)
|
||||
{
|
||||
if (item?.CsoportID.HasValue == true && ((item.TantargyID.HasValue && item.Oraszam.HasValue) || (item.TantargyID.HasValue && model.IsFromSzervezet)))
|
||||
{
|
||||
helper.CreateOrUpdateFelosztas(new TantargyFelosztasCO
|
||||
{
|
||||
TanarID = model.tanarID,
|
||||
OsztalyCsoportID = item.CsoportID.Value,
|
||||
TantargyID = item.TantargyID.Value,
|
||||
Oraszam = item.Oraszam ?? 0,
|
||||
TuloraSzam = item.TuloraSzam ?? 0,
|
||||
OsszevontOra = item.OsszevontOra,
|
||||
NemzetisegiOra = item.NemzetisegiOra,
|
||||
MegbizasiOraszam = item.MegbizasiOraszam ?? 0
|
||||
},
|
||||
isFromSzervezet: model.IsFromSzervezet);
|
||||
}
|
||||
}
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (BlException e)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public DataSourceResult GetTantargyFelosztasokFelvetel(string data, bool isFromSzervezet, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var model = JsonConvert.DeserializeObject<TantargyFelosztasFelveteleModel>(data);
|
||||
var dataSet = new DataSet();
|
||||
var dataTable = new DataTable();
|
||||
dataTable.Columns.Add("ID");
|
||||
dataTable.Columns.Add("OsztalyCsoport");
|
||||
dataTable.Columns.Add("OsztalyCsoportID");
|
||||
dataTable.Columns.Add("Tantargy");
|
||||
dataTable.Columns.Add("TantargyID");
|
||||
dataTable.Columns.Add("Oraszam");
|
||||
dataTable.Columns.Add("Tuloraszam");
|
||||
dataTable.Columns.Add("OsszevontOra");
|
||||
dataTable.Columns.Add("OsszevontOra_BNAME");
|
||||
dataTable.Columns.Add("NemzetisegiOra");
|
||||
dataTable.Columns.Add("NemzetisegiOra_BNAME");
|
||||
dataTable.Columns.Add("MegbizasiOraszam");
|
||||
dataTable.Columns.Add("Valid");
|
||||
|
||||
if (model.TanarId.HasValue)
|
||||
{
|
||||
DataSet tantargyfelosztasDataSet;
|
||||
var helper = new TantargyFelosztasHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
tantargyfelosztasDataSet = helper.GetTantargyFelosztasData(model.TanarId, isFromSzervezet: isFromSzervezet);
|
||||
|
||||
foreach (DataRow dataRow in tantargyfelosztasDataSet.Tables[0].Rows)
|
||||
{
|
||||
dataTable.Rows.Add(
|
||||
dataRow["ID"],
|
||||
dataRow["OsztalyCsoport"],
|
||||
dataRow["OsztalyCsoportID"],
|
||||
dataRow["Tantargy"],
|
||||
dataRow["TantargyID"],
|
||||
dataRow["Oraszam"],
|
||||
dataRow["Tuloraszam"],
|
||||
dataRow["OsszevontOra"],
|
||||
dataRow["OsszevontOra_BNAME"],
|
||||
dataRow["NemzetisegiOra"],
|
||||
dataRow["NemzetisegiOra_BNAME"],
|
||||
dataRow["MegbizasiOraszam"],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
dataTable.Rows.Add(
|
||||
Guid.NewGuid(),
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
false,
|
||||
string.Empty,
|
||||
false,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
dataSet.Tables.Add(dataTable);
|
||||
return dataSet.ToDataSourceResult();
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetTantargyakDD([DataSourceRequest] DataSourceRequest request)
|
||||
{
|
||||
var helper = new TantargyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var tantargyak = helper.GetTanarTantargyaiByTanevCsoportositva(isSzakkepzo: ClaimData.IsSzakkepzoIntezmeny);
|
||||
|
||||
var dropdownListItems = new List<ComboBoxListItem>();
|
||||
foreach (var row in tantargyak)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(row.Value))
|
||||
{
|
||||
var sli = new ComboBoxListItem()
|
||||
{
|
||||
Text = row.Text,
|
||||
Value = row.Value
|
||||
};
|
||||
dropdownListItems.Add(sli);
|
||||
}
|
||||
}
|
||||
|
||||
return Json(dropdownListItems);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage ModifyTantargyFelosztas(TantargyFelosztasModositasaModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (model.Oraszam < model.TuloraSzam)
|
||||
{
|
||||
ModelState.AddModelError("TuloraSzam", TantargyfelosztasResource.ATuloraNemLehetNagyobbMintAzOraszam);
|
||||
}
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var connectionType = ConnectionTypeExtensions.GetSessionConnectionType();
|
||||
var helper = new TantargyFelosztasHelper(connectionType);
|
||||
var orarendiOraHelper = new OrarendiOraHelper(connectionType);
|
||||
|
||||
var eredetiTtf = helper.GetFoglalkozasById(model.Id);
|
||||
var tanarId = Convert.ToInt32(eredetiTtf.Tables[0].Rows[0]["TanarID"]);
|
||||
var tantargyId = Convert.ToInt32(eredetiTtf.Tables[0].Rows[0]["TantargyID"]);
|
||||
var osztalycsoportId = Convert.ToInt32(eredetiTtf.Tables[0].Rows[0]["OsztalyCsoportID"]);
|
||||
var ttfCo = new TantargyFelosztasVisszamenolegesCO
|
||||
{
|
||||
EredetiTanarId = tanarId,
|
||||
EredetiTantargyId = tantargyId,
|
||||
EredetiOsztalyCsoportId = osztalycsoportId,
|
||||
ModosultTanarId = model.TanarId,
|
||||
ModosultTantargyId = model.TantargyId,
|
||||
ModosultOsztalyCsoportId = model.CsoportID
|
||||
};
|
||||
|
||||
if (model.VisszamenolegesModositas)
|
||||
{
|
||||
if (tanarId != model.TanarId)
|
||||
{
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, TantargyResource.VisszamenolegesModositasNemLehetHaTanar);
|
||||
}
|
||||
|
||||
if (!helper.ValidateTantargyfelosztasVisszamenolegesModositas(ttfCo, out var errorMessage))
|
||||
{
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage);
|
||||
}
|
||||
|
||||
if (tantargyId != model.TantargyId || osztalycsoportId != model.CsoportID)
|
||||
{
|
||||
helper.TantargyfelosztasVisszamenolegesModositas(ttfCo);
|
||||
|
||||
new TanuloErtekelesHelper(ConnectionTypeExtensions.GetSessionConnectionType()).AtlagUjraSzamitasVisszamenolegesModositasUtan(ttfCo);
|
||||
}
|
||||
}
|
||||
|
||||
if (model.KapcsolodoOrarendiOrakModositasa)
|
||||
{
|
||||
helper.UpdateOrarendiOraAfterTantargyfelosztasUpdate(ttfCo);
|
||||
}
|
||||
else if (tantargyId != model.TantargyId || osztalycsoportId != model.CsoportID)
|
||||
{
|
||||
helper.RemoveOrarendiOraTTFRelation(model.Id);
|
||||
}
|
||||
|
||||
helper.CreateOrUpdateFelosztas(new TantargyFelosztasCO
|
||||
{
|
||||
ID = model.Id,
|
||||
Oraszam = model.Oraszam,
|
||||
OsztalyCsoportID = model.CsoportID,
|
||||
TanarID = model.TanarId,
|
||||
TantargyID = model.TantargyId,
|
||||
FoglalkozasTipusa = model.TipusId,
|
||||
OsszevontOra = model.OsszevontOra,
|
||||
NemzetisegiOra = model.NemzetisegiOra,
|
||||
MegbizasiOraszam = model.MegbizasiOraszam,
|
||||
TuloraSzam = model.TuloraSzam
|
||||
});
|
||||
|
||||
if (tanarId != model.TanarId)
|
||||
{
|
||||
helper.HandleTanarValtozasOrarendiOrakon(model.Id);
|
||||
}
|
||||
|
||||
orarendiOraHelper.UpdateOrarend();
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
catch (BlException e)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, e.Message);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAMuveletSoran)
|
||||
{
|
||||
UnHandledException = e
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult<string> ModifyTantargyFelosztasConfirmContent(TantargyFelosztasModositasaModel model)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
var helper = new TantargyFelosztasHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var eredetiTtf = helper.GetFoglalkozasById(model.Id);
|
||||
var tanarId = Convert.ToInt32(eredetiTtf.Tables[0].Rows[0]["TanarID"]);
|
||||
var tantargyId = Convert.ToInt32(eredetiTtf.Tables[0].Rows[0]["TantargyID"]);
|
||||
var osztalycsoportId = Convert.ToInt32(eredetiTtf.Tables[0].Rows[0]["OsztalyCsoportID"]);
|
||||
|
||||
var ttfCo = new TantargyFelosztasVisszamenolegesCO
|
||||
{
|
||||
EredetiTanarId = tanarId,
|
||||
EredetiTantargyId = tantargyId,
|
||||
EredetiOsztalyCsoportId = osztalycsoportId,
|
||||
ModosultTanarId = model.TanarId,
|
||||
ModosultTantargyId = model.TantargyId,
|
||||
ModosultOsztalyCsoportId = model.CsoportID
|
||||
};
|
||||
|
||||
if (model.VisszamenolegesModositas)
|
||||
{
|
||||
sb.AppendFormat(TantargyResource.VisszamenolegesModositasFormat,
|
||||
model.TanorakSzama.ToString(), model.ErtekelesekSzama.ToString(), model.MulasztasokSzama.ToString()).AppendLine();
|
||||
if (model.TantargyId != tantargyId)
|
||||
{
|
||||
if (helper.GetEgyszerAdhatoErtekelesekTanatargyfelosztasModositasAlapjan(ttfCo).Count > 0)
|
||||
{
|
||||
sb.AppendLine(TantargyResource.MarLetezikEgyszerAdhatoErtekeles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (model.KapcsolodoOrarendiOrakModositasa)
|
||||
{
|
||||
var m = helper.TantargyfelosztasbanValtozoOrarendiOrak(ttfCo);
|
||||
|
||||
if (m.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
sb.AppendLine(TantargyResource.AtirasraKerulOrarendiElemek);
|
||||
|
||||
foreach (var row in m.Tables[0].AsEnumerable())
|
||||
{
|
||||
var kezdete = DateTime.Parse(row["ErvenyessegKezdete"].ToString()).ToShortDateString();
|
||||
var vege = row["ErvenyessegVege"] != null ? DateTime.Parse(row["ErvenyessegVege"].ToString()).ToShortDateString() : string.Empty;
|
||||
sb.AppendFormat(TantargyResource.AtirasraKerulOrarendiElemekFormat,
|
||||
row["Hetirend"], row["Nap"], row["Ora"], kezdete, vege).AppendLine();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine(TantargyResource.NincsModositandoOrarendiElem);
|
||||
}
|
||||
}
|
||||
|
||||
return Json(sb.ToString());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteTantargyFelosztas([FromBody] int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var helper = new TantargyFelosztasHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
helper.DeleteTargyFelosztas(id);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (Framework.Entities.EntityDeleteFailedException)
|
||||
{
|
||||
var uzenet = string.Format(StringResourcesUtil.GetString(5490), StringResourcesUtil.GetString(1621));
|
||||
throw new StatusError(HttpStatusCode.BadRequest, uzenet);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public IHttpActionResult DeleteSelectedTantargyFelosztas(List<int> idList)
|
||||
{
|
||||
string errorMsg = string.Empty, entityName = string.Empty;
|
||||
var counter = 0;
|
||||
|
||||
var helper = new TantargyFelosztasHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
foreach (var id in idList)
|
||||
{
|
||||
try
|
||||
{
|
||||
helper.DeleteTargyFelosztas(id);
|
||||
counter++;
|
||||
}
|
||||
catch (CannotBeDeletedException ex)
|
||||
{
|
||||
errorMsg += $"{ex.Message}{Environment.NewLine}";
|
||||
continue;
|
||||
}
|
||||
catch (EntityDeleteFailedException ex)
|
||||
{
|
||||
var errorMessage = string.Format(ErrorResource.NemTorolhetoKapcsolatMiatt, OrarendResource.Tantargyfelosztas, ex.ConnectionErrorMessage);
|
||||
|
||||
errorMsg += $"{errorMessage}{Environment.NewLine}{Environment.NewLine}";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.Web.Attributes;
|
||||
using Kreta.Web.Security;
|
||||
|
||||
namespace Kreta.Web.Areas.Tantargy.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue, KretaClaimPackages.Dualis_Admin.ClaimValue, KretaClaimPackages.IsSzakiranyuOktatasertFelelos.ClaimValue)]
|
||||
[KretaGlobalLanguageChangeApiActionFilter(LanguageCode = "hu-Dualis")]
|
||||
public class DualisTantargyFelosztasApiController : BaseTantargyFelosztasApiController
|
||||
{
|
||||
}
|
||||
}
|
326
KretaWeb/Areas/Tantargy/ApiControllers/OraTervApiController.cs
Normal file
326
KretaWeb/Areas/Tantargy/ApiControllers/OraTervApiController.cs
Normal file
|
@ -0,0 +1,326 @@
|
|||
using System.Collections.Generic;
|
||||
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.Security;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Core.Exceptions;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Framework.Entities;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Tantargy.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.Tantargy.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public class OraTervApiController : ApiController
|
||||
{
|
||||
/// <summary>
|
||||
/// Visszaadja a Grid result-ot (1 szint)
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public DataSourceResult GetOraTervGrid(string data, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
OraTervSearchModel model = JsonConvert.DeserializeObject<OraTervSearchModel>(data);
|
||||
|
||||
OratervHelper helper = new OratervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
OratervCO srcCO = Convert_SearchModel_to_CO(model);
|
||||
|
||||
var oraterv = helper.GetOraTerv(srcCO);
|
||||
return oraterv.ToDataSourceResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visszaadja a Grid result-ot (2 szint)
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public DataSourceResult GetOraTervDetailGrid(int oratervId, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
OraTervModel model = new OraTervModel() { OratervId = oratervId };
|
||||
|
||||
OratervHelper helper = new OratervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
OratervCO srcCO = Convert_Model_to_CO(model);
|
||||
|
||||
var oratervTantargy = helper.GetOratervTantargy(srcCO);
|
||||
return oratervTantargy.ToDataSourceResult();
|
||||
}
|
||||
|
||||
public int GetOraTervDetailCount(int oratervId)
|
||||
{
|
||||
OraTervModel model = new OraTervModel() { OratervId = oratervId };
|
||||
|
||||
OratervHelper helper = new OratervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.GridParameters = null;
|
||||
OratervCO srcCO = Convert_Model_to_CO(model);
|
||||
return helper.GetOratervTantargy(srcCO).Tables[0].Rows.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Menti egy ÓraTerv adatait
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveOraTervData(OraTervModel model)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (model.OratervId.HasValue && model.OratervId > 0)
|
||||
{
|
||||
OratervCO co = Convert_Model_to_CO(model);
|
||||
OratervHelper helper = new OratervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
var expression = $"OratervId <> {model.OratervId.Value}";
|
||||
//Egyedi Nev validacio
|
||||
if (helper.GetOraTerv(new OratervCO { Nev = co.Nev, IsValidacio = true }).Tables[0].Select(expression).ToList().Any())
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.DuplikaltOraterv);
|
||||
|
||||
helper.UpdateOratervCO(co);
|
||||
}
|
||||
else
|
||||
{
|
||||
OratervCO co = Convert_Model_to_CO(model);
|
||||
OratervHelper helper = new OratervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
//Egyedi Nev validacio
|
||||
if (helper.GetOraTerv(new OratervCO { Nev = co.Nev, IsValidacio = true }).Tables[0].Rows.Count > 0)
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.DuplikaltOraterv);
|
||||
|
||||
helper.InsertOratervCO(co);
|
||||
}
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tantárgy insert egy OraTervhez
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage AddOraTervTargy(OraTervTargyModel model)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (model.OratervTantargyId.HasValue && model.OratervTantargyId > 0)
|
||||
{
|
||||
OratervTantargyCO co = Convert_Model_to_CO(model);
|
||||
OratervHelper helper = new OratervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.UpdateOratervTantargyCO(co, ClaimData.IsActivTanev);
|
||||
}
|
||||
else
|
||||
{
|
||||
OratervTantargyCO co = Convert_Model_to_CO(model);
|
||||
OratervHelper helper = new OratervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.InsertOratervTantargyCO(co, ClaimData.IsActivTanev);
|
||||
}
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (BlException exception)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, exception.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Töröl egy óratervet
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteOraTerv([FromBody] int oratervID)
|
||||
{
|
||||
if (ClaimData.SelectedTanevID == ClaimData.KovTanevID)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.OratervTorleseCsakAzAktualisTanevbenLehetseges);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OratervHelper helper = new OratervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
if (helper.IfModifyOrDeleteOraTerv(oratervID))
|
||||
{
|
||||
helper.DeleteOratervCO(oratervID);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.TorlesCsakAkkorLehetsegesHaAzOratervhezNincsRogzitveTantargy);
|
||||
|
||||
}
|
||||
catch (EntityDeleteFailedException ex)
|
||||
{
|
||||
var errorMessage = string.Format(ErrorResource.NemTorolhetoKapcsolatMiatt, TantargyResource.Oraterv, ex.ConnectionErrorMessage);
|
||||
|
||||
throw new StatusError(HttpStatusCode.BadRequest, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Töröl egy óraterv tantárgyat
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteOraTervTantargy([FromBody] int tantargyID)
|
||||
{
|
||||
OratervHelper helper = new OratervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.DeleteOratervTantargy(tantargyID);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Törli az összes tantárgyat egy óratervhez
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteAllOraTervTantargy([FromBody] int id)
|
||||
{
|
||||
OratervHelper helper = new OratervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.DeleteAllOratervTantargy(id);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
#region Helpers
|
||||
|
||||
public class ItemModel
|
||||
{
|
||||
public int Id { set; get; }
|
||||
}
|
||||
|
||||
private OratervCO Convert_Model_to_CO(OraTervModel model)
|
||||
{
|
||||
OratervCO co = new OratervCO()
|
||||
{
|
||||
OratervId = model.OratervId,
|
||||
TantervId = model.TantervId,
|
||||
Evfolyam = model.EvfolyamId ?? 0,
|
||||
Nev = model.Nev
|
||||
};
|
||||
return co;
|
||||
}
|
||||
|
||||
private OratervCO Convert_SearchModel_to_CO(OraTervSearchModel model)
|
||||
{
|
||||
OratervCO co = new OratervCO()
|
||||
{
|
||||
TantervId = model.TantervIdSearch,
|
||||
Evfolyam = model.EvfolyamIdSearch ?? 0,
|
||||
Nev = model.NevSearch
|
||||
};
|
||||
return co;
|
||||
}
|
||||
|
||||
private OratervTantargyCO Convert_Model_to_CO(OraTervTargyModel model)
|
||||
{
|
||||
OratervTantargyCO co = new OratervTantargyCO()
|
||||
{
|
||||
OratervId = model.OratervId,
|
||||
EvesOraszam = model.EvesOraszam.Value,
|
||||
Tantargy = model.TantargyId.Value,
|
||||
OratervTantargyId = model.OratervTantargyId
|
||||
};
|
||||
return co;
|
||||
}
|
||||
|
||||
private OraTervModel Convert_CO_to_Model(OratervCO co)
|
||||
{
|
||||
OraTervModel model = new OraTervModel()
|
||||
{
|
||||
OratervId = co.OratervId,
|
||||
TantervId = co.TantervId,
|
||||
EvfolyamId = co.Evfolyam,
|
||||
Nev = co.Nev
|
||||
};
|
||||
return model;
|
||||
}
|
||||
|
||||
private OraTervTargyModel Convert_TantargyCO_to_Model(OratervTantargyCO co)
|
||||
{
|
||||
OraTervTargyModel model = new OraTervTargyModel()
|
||||
{
|
||||
OratervId = co.OratervId,
|
||||
EvesOraszam = co.EvesOraszam,
|
||||
TantargyId = co.Tantargy
|
||||
};
|
||||
return model;
|
||||
}
|
||||
|
||||
public OraTervModel GetOraTervElem(int id)
|
||||
{
|
||||
OratervCO co;
|
||||
|
||||
var helper = new OratervHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
co = helper.GetOratervCO(id);
|
||||
|
||||
OraTervModel model = Convert_CO_to_Model(co);
|
||||
return model;
|
||||
}
|
||||
|
||||
public OraTervTargyModel GetOraTervTantargyElem(int id)
|
||||
{
|
||||
OratervTantargyCO co;
|
||||
|
||||
var helper = new OratervHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
co = helper.GetOratervTantargyCO(id);
|
||||
|
||||
OraTervTargyModel model = Convert_TantargyCO_to_Model(co);
|
||||
return model;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// NOTE: Kiszervezni -> GetTantervList ComboBoxHelperApi
|
||||
public JsonResult<List<ComboBoxListItem>> GetTantervList([DataSourceRequest] DataSourceRequest request)
|
||||
{
|
||||
var helper = new TantervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var dictionary = helper.GetTanterv("");
|
||||
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);
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetEvfolyamList([DataSourceRequest] DataSourceRequest request)
|
||||
{
|
||||
List<ComboBoxListItem> items = ((int)GeneratedAdatszotarTipusEnum.EvfolyamTipus).GetItemsByType(ClaimData.SelectedTanevID.Value, true).ToComboBoxItemList();
|
||||
|
||||
return Json(items);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace Kreta.Web.Areas.Tantargy.ApiControllers
|
||||
{
|
||||
public class TanmenetApiController : BaseTanmenetApiController
|
||||
{
|
||||
|
||||
}
|
||||
}
|
113
KretaWeb/Areas/Tantargy/ApiControllers/TanorakApiController.cs
Normal file
113
KretaWeb/Areas/Tantargy/ApiControllers/TanorakApiController.cs
Normal file
|
@ -0,0 +1,113 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.ModelBinding;
|
||||
using Kendo.Mvc.UI;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Logic;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.Core;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Tantargy.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.Tantargy.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Naplo.ClaimValue)]
|
||||
public class TanorakApiController : ApiController
|
||||
{
|
||||
public DataSourceResult GetTanorakGrid(string data, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
TanorakSearchModel model = JsonConvert.DeserializeObject<TanorakSearchModel>(data);
|
||||
|
||||
var helper = new TanoraHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
|
||||
var ret = helper.GetTanorak(ConvertTanorakSearchModelToTanorakSearchCO(model));
|
||||
|
||||
return ret.ToDataSourceResult();
|
||||
}
|
||||
|
||||
public DataSourceResult GetTanorakGridForNaplozas(int osztalyCsoportId, int tantargyId, DateTime oraKezdete, DataSourceRequest request)
|
||||
{
|
||||
var model = new TanorakSearchModel
|
||||
{
|
||||
OsztalyCsoportId = osztalyCsoportId,
|
||||
TantargyId = tantargyId,
|
||||
OraKezdete = oraKezdete
|
||||
};
|
||||
|
||||
var (gridParameter, modelList) = GetGridData(model, request);
|
||||
|
||||
return modelList.ToDataSourceResult(gridParameter);
|
||||
}
|
||||
|
||||
public HttpResponseMessage GetExport(int osztalyCsoportId, int tantargyId, DataSourceRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var model = new TanorakSearchModel
|
||||
{
|
||||
OsztalyCsoportId = osztalyCsoportId,
|
||||
TantargyId = tantargyId
|
||||
};
|
||||
|
||||
var (gridParameter, modelList) = GetGridData(model, request);
|
||||
|
||||
modelList = modelList.SortingAndPaging(gridParameter.OrderDictionary);
|
||||
|
||||
var simpleExportColumnCos = SimpleExportLogic.GetSimpleExportColumnCos<TanorakGridModel>(TanorakGridModel.TanorakExportAttributeId);
|
||||
|
||||
var memoryStream = SimpleExportLogic.GetExport(OrarendResource.KorabbiOrakNaplozasiAdataiExportSheetName, simpleExportColumnCos, modelList, ClaimData.SelectedTanevID.Value);
|
||||
|
||||
return HttpResponseExtensions.GetFileHttpResponse(memoryStream.ToArray(), $"{OrarendResource.KorabbiOrakNaplozasiAdatai_Export}_{DateTime.Now:yyyy_MM_dd}.xlsx");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAFajlExportalasaKozben) { UnHandledException = ex };
|
||||
}
|
||||
}
|
||||
|
||||
private (GridParameters gridParameter, List<TanorakGridModel> modelList) GetGridData(TanorakSearchModel model, DataSourceRequest request)
|
||||
{
|
||||
var gridParameter = Converter.GridParameter(request);
|
||||
|
||||
var coList = new TanoraHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetTanorakGridForNaplozasCoList(ConvertTanorakSearchModelToTanorakSearchCO(model));
|
||||
|
||||
var modelList = new List<TanorakGridModel>();
|
||||
foreach (var co in coList)
|
||||
{
|
||||
var gridModel = new TanorakGridModel(co);
|
||||
modelList.Add(gridModel);
|
||||
}
|
||||
|
||||
return (gridParameter, modelList);
|
||||
}
|
||||
|
||||
private TanorakSearchCO ConvertTanorakSearchModelToTanorakSearchCO(TanorakSearchModel model)
|
||||
{
|
||||
TanorakSearchCO co = new TanorakSearchCO
|
||||
{
|
||||
IdoszakKezdete = model.IdoszakKezdete,
|
||||
IdoszakVege = model.IdoszakVege,
|
||||
OsztalyCsoportId = model.OsztalyCsoportId,
|
||||
Helyetesitett = model.Helyetesitett,
|
||||
TantargyId = model.TantargyId,
|
||||
TanarId = model.TanarId,
|
||||
OraKezdete = model.OraKezdete,
|
||||
};
|
||||
|
||||
return co;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
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.Security;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Tantargy.Models;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Helpers.Error;
|
||||
using Kreta.Web.Security;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kreta.Web.Areas.Tantargy.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public class TantargyFelosztasApiController : BaseTantargyFelosztasApiController
|
||||
{
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ExportLepedoOsztalyTantargyfelosztas(string data, bool isFromSzervezet = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var model = JsonConvert.DeserializeObject<TantargyFelosztasModel>(data);
|
||||
|
||||
var memoryStream = new BusinessLogic.Classes.ExcelHelpers.TTFExportHelper(ConnectionTypeExtensions.GetSessionConnectionType()).ExportLepedoOsztalyTTF(model.SearchTanar, model.SearchOsztalCsoport, model.SearchTantargy, targyKatId: null, evfolyamId: model.SearchEvfolyam, foglalkozasTipusId: model.SearchFoglalkozasTipusa, feladatKategoriaId: model.SearchFeladatKategoriaId, feladatellatasiHelyId: model.SearchFeladatellatasihely, oraszam: model.SearchOraszam, isImportalt: null, osztalybontasokkal: model.Osztalybontasokkal, kapcsolodoCsoportokkal: model.KapcsolodoCsoportokkal, isFromSzervezet: model.IsFromSzervezet);
|
||||
|
||||
return HttpResponseExtensions.GetFileHttpResponse(memoryStream.ToArray(), $"{ClaimData.IntezmenyAzonosito}_{TantargyResource.Tantargyfelosztas_Export}_{DateTime.Now:yyyy_MM_dd}.xlsx");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAFajlExportalasaKozben) { UnHandledException = ex };
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ExportLepedoTantargyfelosztas(string data)
|
||||
{
|
||||
try
|
||||
{
|
||||
var model = JsonConvert.DeserializeObject<TantargyFelosztasModel>(data);
|
||||
|
||||
var memoryStream = new BusinessLogic.Classes.ExcelHelpers.TTFExportHelper(ConnectionTypeExtensions.GetSessionConnectionType()).ExportLepedoTTF(model.SearchTanar, model.SearchOsztalCsoport, model.SearchTantargy, targyKatId: null, evfolyamId: model.SearchEvfolyam, foglalkozasTipusId: model.SearchFoglalkozasTipusa, feladatKategoriaId: model.SearchFeladatKategoriaId, feladatellatasiHelyId: model.SearchFeladatellatasihely, oraszam: model.SearchOraszam, isImportalt: null, osztalybontasokkal: model.Osztalybontasokkal, kapcsolodoCsoportokkal: model.KapcsolodoCsoportokkal, isFromSzervezet: model.IsFromSzervezet);
|
||||
|
||||
return HttpResponseExtensions.GetFileHttpResponse(memoryStream.ToArray(), $"{ClaimData.IntezmenyAzonosito}_{TantargyResource.Tantargyfelosztas_Export}_{DateTime.Now:yyyy_MM_dd}.xlsx");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAFajlExportalasaKozben) { UnHandledException = ex };
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ExportEgyszeruTantargyfelosztas(string data)
|
||||
{
|
||||
try
|
||||
{
|
||||
var model = JsonConvert.DeserializeObject<TantargyFelosztasModel>(data);
|
||||
|
||||
var memoryStream = new BusinessLogic.Classes.ExcelHelpers.TTFExportHelper(ConnectionTypeExtensions.GetSessionConnectionType()).ExportEgyszeruTTF(model.SearchTanar, model.SearchOsztalCsoport, model.SearchTantargy, targyKatId: null, evfolyamId: model.SearchEvfolyam, foglalkozasTipusId: model.SearchFoglalkozasTipusa, feladatKategoriaId: model.SearchFeladatKategoriaId, feladatellatasiHelyId: model.SearchFeladatellatasihely, oraszam: model.SearchOraszam, isImportalt: null, osztalybontasokkal: model.Osztalybontasokkal, kapcsolodoCsoportokkal: model.KapcsolodoCsoportokkal, isFromSzervezet: model.IsFromSzervezet);
|
||||
|
||||
return HttpResponseExtensions.GetFileHttpResponse(memoryStream.ToArray(), $"{ClaimData.IntezmenyAzonosito}_{TantargyResource.Tantargyfelosztas_Export}_{DateTime.Now:yyyy_MM_dd}.xlsx");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAFajlExportalasaKozben) { UnHandledException = ex };
|
||||
}
|
||||
}
|
||||
|
||||
public IntezmenyCO GetIntezmenyAdatok() => new IntezmenyHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetIntezmenyiAdatok();
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public JsonResult<List<ComboBoxListItem>> GetEvfolyamok([DataSourceRequest] DataSourceRequest request)
|
||||
{
|
||||
List<ComboBoxListItem> items = ((int)GeneratedAdatszotarTipusEnum.EvfolyamTipus).GetItemsByType(ClaimData.SelectedTanevID.Value, true).ToComboBoxItemList();
|
||||
|
||||
return Json(items);
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public JsonResult<List<ComboBoxListItem>> GetFoglalkozasTipusok([DataSourceRequest] DataSourceRequest request)
|
||||
{
|
||||
List<ComboBoxListItem> items = ((int)GeneratedAdatszotarTipusEnum.FoglalkozasTipus).GetItemsByType(ClaimData.SelectedTanevID.Value, true).ToComboBoxItemList();
|
||||
|
||||
return Json(items);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
265
KretaWeb/Areas/Tantargy/ApiControllers/TantervekApiController.cs
Normal file
265
KretaWeb/Areas/Tantargy/ApiControllers/TantervekApiController.cs
Normal file
|
@ -0,0 +1,265 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.ModelBinding;
|
||||
using Kendo.Mvc.UI;
|
||||
using Kreta.BusinessLogic.Classes;
|
||||
using Kreta.BusinessLogic.Classes.ComboBox;
|
||||
using Kreta.BusinessLogic.Exceptions;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.Exceptions;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Framework.Entities;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Tantargy.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.Tantargy.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public class TantervekApiController : ApiController
|
||||
{
|
||||
public DataSourceResult GetTantervekGrid(string data, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
TantervSearchModel model = JsonConvert.DeserializeObject<TantervSearchModel>(data);
|
||||
|
||||
TantervHelper helper = new TantervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
var tantervek = helper.TantervKereses(model.TantervNev, model.JellemzoCsopTipID, model.KezdoEvfolyamID, model.VegzoEvfolyamID, model.IsKerettantervreEpul, model.IsKerettantervSrc);
|
||||
return tantervek.ToDataSourceResult();
|
||||
}
|
||||
|
||||
public TantervModel GetTantervProperties(int tantervID)
|
||||
{
|
||||
TantervCO co;
|
||||
|
||||
TantervHelper thelper = new TantervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
co = thelper.GetCo(tantervID);
|
||||
|
||||
return ConvertCOtoModel(co);
|
||||
}
|
||||
|
||||
public TantervModModel GetTantervPropertiesMod(int tantervID)
|
||||
{
|
||||
TantervHelper thelper = new TantervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
TantervCO co = thelper.GetCo(tantervID);
|
||||
TantervModModel model = new TantervModModel()
|
||||
{
|
||||
ID = co.ID,
|
||||
Nev = co.Nev,
|
||||
CsoportTipusa = co.CsoportTipusa,
|
||||
Evfolyamtol = co.Evfolyamtol,
|
||||
Evfolyamig = co.Evfolyamig,
|
||||
KerettantervreEpulo = co.KerettantervreEpulo.ToNullableInt(),
|
||||
IsKerettanterv = co.IsKerettanterv.ToNullableInt()
|
||||
};
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public DataSourceResult GetTantervOSztalyai(string tantervID, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var helper = new TantervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
|
||||
var ds = helper.GetTantervOsztalyai(SDAConvert.ToInt32(tantervID));
|
||||
|
||||
return ds.ToDataSourceResult();
|
||||
}
|
||||
|
||||
public DataSourceResult GetTantervTanuloi(string tantervID, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var helper = new TantervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
|
||||
var ds = helper.GetTantervTanuloi(SDAConvert.ToInt32(tantervID));
|
||||
|
||||
return ds.ToDataSourceResult();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveModifiedOrNewTanterv(TantervModel tmodel)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
TantervCO co = ConvertModelToCO(tmodel);
|
||||
TantervHelper helper = new TantervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
if (co.ID.HasValue)
|
||||
{
|
||||
helper.Update(co);
|
||||
}
|
||||
else
|
||||
{
|
||||
helper.Insert(co);
|
||||
}
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
catch (SDA.DataProvider.SDADataProviderException ex)
|
||||
{
|
||||
if (ex.Error == SDA.DataProvider.SDADataProviderError.UniqueKeyViolation)
|
||||
{
|
||||
string msg = string.Format(StringResourcesUtil.GetString(3554), StringResourcesUtil.GetString(1589 /*Tanterv neve*/));
|
||||
ModelState.AddModelError("Nev", msg);
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
|
||||
throw;
|
||||
|
||||
}
|
||||
catch (CannotBeInsertedException e)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public HttpResponseMessage SaveModTanterv(TantervModModel tmodel)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var co = ConvertModModelToCO(tmodel);
|
||||
var helper = new TantervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
if (string.IsNullOrWhiteSpace(tmodel.TantervIDArray))
|
||||
{
|
||||
helper.TantervTobbesModify(co);
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] tantervIDArray = tmodel.TantervIDArray.Split(',');
|
||||
foreach (var item in tantervIDArray)
|
||||
{
|
||||
co.ID = int.Parse(item);
|
||||
helper.TantervTobbesModify(co);
|
||||
}
|
||||
}
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
catch (CannotBeInsertedException e)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, e.Message);
|
||||
}
|
||||
catch (BlException e)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private TantervTobbesModCO ConvertModModelToCO(TantervModModel model)
|
||||
{
|
||||
return new TantervTobbesModCO()
|
||||
{
|
||||
ID = model.ID,
|
||||
CsoportTipusa = model.CsoportTipusa,
|
||||
Evfolyamig = model.Evfolyamig,
|
||||
Evfolyamtol = model.Evfolyamtol,
|
||||
KerettantervreEpulo = model.KerettantervreEpulo,
|
||||
IsKerettanterv = model.IsKerettanterv
|
||||
};
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteTanterv([FromBody] int tantervID)
|
||||
{
|
||||
if (ClaimData.SelectedTanevID == ClaimData.KovTanevID)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.TantervTorleseCsakAzAktualisTanevbenLehetseges);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
TantervHelper helper = new TantervHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
var ds = helper.GetAktivTantervDataSet();
|
||||
if (ds.Tables[0].Rows.Count == 1)
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.Legalabb1TantervLetezne);
|
||||
|
||||
helper.Delete(tantervID);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (BlException exception)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, exception.Message);
|
||||
}
|
||||
catch (EntityDeleteFailedException ex)
|
||||
{
|
||||
|
||||
var uzenet = string.Format(ErrorResource.NemTorolhetoKapcsolatMiatt, TanuloResource.Tanterv, ex.ConnectionErrorMessage);
|
||||
throw new StatusError(HttpStatusCode.BadRequest, uzenet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private TantervCO ConvertModelToCO(TantervModel tmodel)
|
||||
{
|
||||
TantervCO co = new TantervCO()
|
||||
{
|
||||
CsoportTipusa = tmodel.CsoportTipusa ?? -1,
|
||||
Evfolyamig = tmodel.Evfolyamig ?? -1,
|
||||
Evfolyamtol = tmodel.Evfolyamtol ?? -1,
|
||||
ID = tmodel.ID,
|
||||
KerettantervreEpulo = tmodel.KerettantervreEpulo,
|
||||
Megjegyzes = tmodel.Megjegyzes,
|
||||
Nev = tmodel.Nev,
|
||||
IsKerettanterv = tmodel.IsKerettanterv
|
||||
};
|
||||
|
||||
return co;
|
||||
}
|
||||
|
||||
private TantervModel ConvertCOtoModel(TantervCO co)
|
||||
{
|
||||
TantervModel model = new TantervModel()
|
||||
{
|
||||
CsoportTipusa = co.CsoportTipusa,
|
||||
Evfolyamig = co.Evfolyamig,
|
||||
Evfolyamtol = co.Evfolyamtol,
|
||||
ID = co.ID,
|
||||
KerettantervreEpulo = co.KerettantervreEpulo,
|
||||
Megjegyzes = co.Megjegyzes,
|
||||
Nev = co.Nev,
|
||||
IsKerettanterv = co.IsKerettanterv
|
||||
};
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public System.Web.Http.Results.JsonResult<List<ComboBoxListItem>> GetEvfolyamListS([DataSourceRequest] DataSourceRequest request)
|
||||
{
|
||||
List<ComboBoxListItem> items = ((int)GeneratedAdatszotarTipusEnum.EvfolyamTipus).GetItemsByType(ClaimData.SelectedTanevID.Value, true).ToComboBoxItemList();
|
||||
|
||||
return Json(items);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
using Kreta.Web.Attributes;
|
||||
|
||||
namespace Kreta.Web.Areas.Tantargy.ApiControllers
|
||||
{
|
||||
[KretaGlobalLanguageChangeApiActionFilter(LanguageCode = "hu-Dualis")]
|
||||
public class TanulasiElemekApiController : BaseTanmenetApiController
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue