init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,187 @@
|
|||
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.Logic;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Core;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Enums.ManualEnums;
|
||||
using Kreta.Framework.Entities;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.TanuloErtekeles.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.TanuloErtekeles.ApiControllers
|
||||
{
|
||||
public class BaseFeljegyzesekApiController : ApiController
|
||||
{
|
||||
[NonAction]
|
||||
public HttpResponseMessage GetExport(string data, DataSourceRequest request, string exportSheetName, string exportFileName, string exportAttributeId, bool isFaliujsag = false, SzervezetTipusEnum? szervezetTipus = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var (gridParameter, modelList) = GetGridData(data, request, isFaliujsag, szervezetTipus);
|
||||
|
||||
modelList = modelList.SortingAndPaging(gridParameter.OrderDictionary);
|
||||
|
||||
var simpleExportColumnCos = SimpleExportLogic.GetSimpleExportColumnCos<FeljegyzesKeresoGridModel>(exportAttributeId);
|
||||
|
||||
var memoryStream = SimpleExportLogic.GetExport(exportSheetName, simpleExportColumnCos, modelList, ClaimData.SelectedTanevID.Value);
|
||||
|
||||
return HttpResponseExtensions.GetFileHttpResponse(memoryStream.ToArray(), exportFileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaTortentAFajlExportalasaKozben) { UnHandledException = ex };
|
||||
}
|
||||
}
|
||||
|
||||
public (GridParameters gridParameter, List<FeljegyzesKeresoGridModel> modelList) GetGridData(string data, DataSourceRequest request, bool isFaliujsag = false, SzervezetTipusEnum? szervezetTipus = null)
|
||||
{
|
||||
var model = JsonConvert.DeserializeObject<FeljegyzesKeresoModel>(data);
|
||||
|
||||
if (szervezetTipus.HasValue)
|
||||
{
|
||||
model.SzervezetTipusId = (int)szervezetTipus;
|
||||
}
|
||||
|
||||
var gridParameter = Converter.GridParameter(request);
|
||||
|
||||
var modelList = new List<FeljegyzesKeresoGridModel>();
|
||||
if (isFaliujsag)
|
||||
{
|
||||
var coList = new FeljegyzesekHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetFaliujsagFeljegyzesCoList(model.ToCo());
|
||||
foreach (var co in coList)
|
||||
{
|
||||
var gridModel = new FeljegyzesKeresoGridModel(co);
|
||||
modelList.Add(gridModel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var coList = new FeljegyzesekHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetFeljegyzesekCoList(model.ToCo());
|
||||
foreach (var co in coList)
|
||||
{
|
||||
var gridModel = new FeljegyzesKeresoGridModel(co);
|
||||
modelList.Add(gridModel);
|
||||
}
|
||||
}
|
||||
|
||||
return (gridParameter, modelList);
|
||||
}
|
||||
|
||||
public class DeleteElektronikusUzenetModel
|
||||
{
|
||||
public int FeljegyzesId { get; set; }
|
||||
|
||||
public int TanuloId { get; set; }
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteFeljegyzes([FromBody] int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var helper = new FeljegyzesHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
helper.DeleteFeljegyzes(id);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (EntityDeleteFailedException ex)
|
||||
{
|
||||
var uzenet = string.Format(ErrorResource.NemTorolhetoKapcsolatMiatt, FeljegyzesekResource.Feljegyzes, ex.ConnectionErrorMessage);
|
||||
throw new StatusError(HttpStatusCode.BadRequest, uzenet);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteElektronikusUzenet(DeleteElektronikusUzenetModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var helper = new FeljegyzesHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
helper.DeleteElektronikusUzenetForTanulo(model.FeljegyzesId, model.TanuloId);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (EntityDeleteFailedException ex)
|
||||
{
|
||||
var uzenet = string.Format(ErrorResource.NemTorolhetoKapcsolatMiatt, FeljegyzesekResource.ElektronikusUzenet, ex.ConnectionErrorMessage);
|
||||
throw new StatusError(HttpStatusCode.BadRequest, uzenet);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteOsztalyCsoport(List<FeljegyzesDeleteOsztalyCsoportModel> feljegyzesDeleteOsztalyCsoportList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var feljegyzesHelper = new FeljegyzesHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
var feljegyzesDeleteOsztalyCsoportCoList = new List<FeljegyzesDeleteOsztalyCsoportCO>();
|
||||
foreach (var deleteItem in feljegyzesDeleteOsztalyCsoportList)
|
||||
{
|
||||
feljegyzesDeleteOsztalyCsoportCoList.Add(new FeljegyzesDeleteOsztalyCsoportCO
|
||||
{
|
||||
FeljegyzesId = deleteItem.FeljegyzesId,
|
||||
OsztalyCsoportId = deleteItem.OsztalyCsoportId
|
||||
});
|
||||
}
|
||||
|
||||
feljegyzesHelper.DeleteOsztalyCsoport(feljegyzesDeleteOsztalyCsoportCoList);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (EntityDeleteFailedException ex)
|
||||
{
|
||||
var uzenet = string.Format(FeljegyzesekResource.NemTorolhetoKapcsolodasMiatt, FeljegyzesekResource.Feljegyzes, ex.ConnectionErrorMessage);
|
||||
throw new StatusError(HttpStatusCode.BadRequest, uzenet);
|
||||
}
|
||||
}
|
||||
|
||||
public static FeljegyzesModel ConvertFeljegyzesCoToModel(FeljegyzesekCO co)
|
||||
{
|
||||
var model = new FeljegyzesModel
|
||||
{
|
||||
Datum = co.Datum,
|
||||
TanuloId = co.TanuloId,
|
||||
TanuloNev = co.TanuloNev,
|
||||
OsztalyId = co.OsztalyId,
|
||||
OsztalyNev = co.OsztalyNev,
|
||||
FeljegyzoId = co.TanarId,
|
||||
FeljegyzoNev = co.TanarNev,
|
||||
Tipus = co.Tipus,
|
||||
Megjegyzes = co.Megjegyzes,
|
||||
Tartalom = co.Tartalom,
|
||||
Cim = co.Cim,
|
||||
FeljegyzesRogzitesenekDatuma = co.FeljegyzesRogzitesenekDatuma,
|
||||
};
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public JsonResult<List<ComboBoxListItem>> GetFeljegyzesTipusList()
|
||||
{
|
||||
var items = FrameworkEnumExtensions.EnumToList((int)GeneratedAdatszotarTipusEnum.EsemenyTipus, ClaimData.SelectedTanevID.Value);
|
||||
var result = items.ToComboBoxItemList(new List<string>
|
||||
{
|
||||
((int)EsemenyTipusEnum.ElektronikusUzenet).ToString(),
|
||||
((int)EsemenyTipusEnum.FaliujsagBejegyzes).ToString()
|
||||
});
|
||||
return Json(result);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue