init
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using Kendo.Mvc.UI;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.Client.KGR;
|
||||
using Kreta.Client.KGR.Request;
|
||||
using Kreta.Web.Areas.GRModul.Models;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Helpers.Grid;
|
||||
using Kreta.Web.Security;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kreta.Web.Areas.GRModul.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Naplo.ClaimValue)]
|
||||
public class ProjektApiController : ApiController
|
||||
{
|
||||
private readonly IKGRClient kgrClient;
|
||||
|
||||
public ProjektApiController(IKGRClient kgrClient)
|
||||
{
|
||||
this.kgrClient = kgrClient ?? throw new ArgumentNullException(nameof(kgrClient));
|
||||
}
|
||||
|
||||
public DataSourceResult GetProjektGrid(string data, [System.Web.Http.ModelBinding.ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProjektSearchModel model = JsonConvert.DeserializeObject<ProjektSearchModel>(data);
|
||||
List<ProjektGridModel> LProjekt = new List<ProjektGridModel>();
|
||||
List<ProjektGridModel> LResult = new List<ProjektGridModel>();
|
||||
|
||||
var kozpontiResult = kgrClient.ProjektList(new ProjektHeaderRequest() { IntezmenyGuid = ClaimData.IntezmenyGuid.ToString(), AlkalmazottId = ClaimData.FelhasznaloId });
|
||||
if (kozpontiResult != null)
|
||||
{
|
||||
foreach (var item in kozpontiResult)
|
||||
{
|
||||
LProjekt.Add(new ProjektGridModel()
|
||||
{
|
||||
ID = item.Id.ToString(),
|
||||
ProjektAzonosito = item.Azonosito,
|
||||
ProjektNeve = item.Nev,
|
||||
ProjektKezdete = item.Kezdete,
|
||||
ProjektVege = item.Vege,
|
||||
TSZTOMegkotesDatum = item.TSZTOMegkotesDatum,
|
||||
HataridoKezdet = item.JelentkezesHataridoKezdet,
|
||||
HataridoVeg = item.JelentkezesHataridoVeg,
|
||||
IsVisszautasitott = item.IsVisszautasitott,
|
||||
IsJelentkezett = item.IsJelentkezett,
|
||||
IsElfogadott = item.IsElfogadott
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(model.SrcProjektAzonosito))
|
||||
LProjekt = LProjekt.Where(x => x.ProjektAzonosito.ToLower().Contains(model.SrcProjektAzonosito.ToLower())).ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(model.SrcProjektNeve))
|
||||
LProjekt = LProjekt.Where(x => x.ProjektNeve.ToLower().Contains(model.SrcProjektNeve.ToLower())).ToList();
|
||||
|
||||
if (model.SrcProjektKezdete.HasValue)
|
||||
LProjekt = LProjekt.Where(x => x.ProjektKezdete.Value.Date >= model.SrcProjektKezdete.Value.Date).ToList();
|
||||
|
||||
if (model.SrcProjektVege.HasValue)
|
||||
LProjekt = LProjekt.Where(x => x.ProjektVege.Value.Date <= model.SrcProjektVege.Value.Date).ToList();
|
||||
|
||||
if (model.SrcTSZTOMegkotesDatum.HasValue)
|
||||
LProjekt = LProjekt.Where(x => x.TSZTOMegkotesDatum.Value.Date >= model.SrcTSZTOMegkotesDatum.Value.Date).ToList();
|
||||
|
||||
if (model.SrcJelentkezesiHataridoKezdete.HasValue)
|
||||
LProjekt = LProjekt.Where(x => x.HataridoKezdet.HasValue && x.HataridoKezdet.Value.Date >= model.SrcJelentkezesiHataridoKezdete.Value.Date).ToList();
|
||||
|
||||
if (model.SrcJelentkezesiHataridoVege.HasValue)
|
||||
LProjekt = LProjekt.Where(x => x.HataridoVeg.HasValue && x.HataridoVeg.Value.Date >= model.SrcJelentkezesiHataridoVege.Value.Date).ToList();
|
||||
|
||||
if (LProjekt.Count > 0)
|
||||
{
|
||||
if (request.Sorts.Count == 1)
|
||||
{
|
||||
var sort = request.Sorts[0];
|
||||
if (sort.Member == "ProjektAzonosito" && sort.SortDirection == ListSortDirection.Ascending)
|
||||
{ LResult = LProjekt.OrderBy(x => x.ProjektAzonosito).ToList(); }
|
||||
if (sort.Member == "ProjektAzonosito" && sort.SortDirection == ListSortDirection.Descending)
|
||||
{ LResult = LProjekt.OrderByDescending(x => x.ProjektAzonosito).ToList(); }
|
||||
|
||||
if (sort.Member == "ProjektNeve" && sort.SortDirection == ListSortDirection.Ascending)
|
||||
{ LResult = LProjekt.OrderBy(x => x.ProjektNeve).ToList(); }
|
||||
if (sort.Member == "ProjektNeve" && sort.SortDirection == ListSortDirection.Descending)
|
||||
{ LResult = LProjekt.OrderByDescending(x => x.ProjektNeve).ToList(); }
|
||||
|
||||
if (sort.Member == "ProjektKezdete" && sort.SortDirection == ListSortDirection.Ascending)
|
||||
{ LResult = LProjekt.OrderBy(x => x.ProjektKezdete).ToList(); }
|
||||
if (sort.Member == "ProjektKezdete" && sort.SortDirection == ListSortDirection.Descending)
|
||||
{ LResult = LProjekt.OrderByDescending(x => x.ProjektKezdete).ToList(); }
|
||||
|
||||
if (sort.Member == "ProjektVege" && sort.SortDirection == ListSortDirection.Ascending)
|
||||
{ LResult = LProjekt.OrderBy(x => x.ProjektVege).ToList(); }
|
||||
if (sort.Member == "ProjektVege" && sort.SortDirection == ListSortDirection.Descending)
|
||||
{ LResult = LProjekt.OrderByDescending(x => x.ProjektVege).ToList(); }
|
||||
|
||||
if (sort.Member == "TSZTOMegkotesDatum" && sort.SortDirection == ListSortDirection.Ascending)
|
||||
{ LResult = LProjekt.OrderBy(x => x.TSZTOMegkotesDatum).ToList(); }
|
||||
if (sort.Member == "TSZTOMegkotesDatum" && sort.SortDirection == ListSortDirection.Descending)
|
||||
{ LResult = LProjekt.OrderByDescending(x => x.TSZTOMegkotesDatum).ToList(); }
|
||||
|
||||
if (sort.Member == "HataridoKezdet" && sort.SortDirection == ListSortDirection.Ascending)
|
||||
{ LResult = LProjekt.OrderBy(x => x.HataridoKezdet).ToList(); }
|
||||
if (sort.Member == "HataridoKezdet" && sort.SortDirection == ListSortDirection.Descending)
|
||||
{ LResult = LProjekt.OrderByDescending(x => x.HataridoKezdet).ToList(); }
|
||||
|
||||
if (sort.Member == "HataridoVeg" && sort.SortDirection == ListSortDirection.Ascending)
|
||||
{ LResult = LProjekt.OrderBy(x => x.HataridoVeg).ToList(); }
|
||||
if (sort.Member == "HataridoVeg" && sort.SortDirection == ListSortDirection.Descending)
|
||||
{ LResult = LProjekt.OrderByDescending(x => x.HataridoVeg).ToList(); }
|
||||
}
|
||||
else
|
||||
{
|
||||
LResult = LProjekt.ToList();
|
||||
}
|
||||
|
||||
var cnt = LResult.Count;
|
||||
var result = LResult.ToDataSourceResult();
|
||||
result.Total = cnt;
|
||||
result.Data = GetPage(LResult, request.Page, request.PageSize, cnt);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return new DataSourceResult();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new DataSourceResult();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveJelentkezes([FromBody] int projektId)
|
||||
{
|
||||
var co = new FelhasznaloHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetProjektFelhasznaloData();
|
||||
var kozpontiResult = kgrClient.ProjektJelentkezes(
|
||||
new Client.KGR.Model.ProjektJelentkezesModel()
|
||||
{
|
||||
IntezmenyId = ClaimData.IntezmenyGuid.Value,
|
||||
OktatasiAzonosito = co.OktatasiAzonosito,
|
||||
IdpEgyediazonosito = Guid.Parse(co.IdpEgyediAzonosito),
|
||||
AlkalmazottNev = co.NyomtatasiNev,
|
||||
ProjektId = projektId,
|
||||
AlkalmazottId = ClaimData.FelhasznaloId,
|
||||
IsJelentkezett = true,
|
||||
Retrieve = true
|
||||
}
|
||||
);
|
||||
|
||||
if (kozpontiResult != null)
|
||||
{
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Hiba a jelentkezés során!");
|
||||
}
|
||||
|
||||
List<ProjektGridModel> GetPage(List<ProjektGridModel> list, int page, int pageSize, int fullCnt)
|
||||
{
|
||||
page--;
|
||||
return list.Skip(page * pageSize).Take(pageSize).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user