init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,589 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web.Http;
|
||||
using Kendo.Mvc.UI;
|
||||
using Kreta.BusinessLogic.Classes;
|
||||
using Kreta.BusinessLogic.Exceptions;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Interfaces;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.Exceptions;
|
||||
using Kreta.Core.Iktato.Poszeidon.Factory.Interface;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Framework.Entities;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Intezmeny.Models;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Helpers.Error;
|
||||
using Kreta.Web.Helpers.Grid;
|
||||
using Kreta.Web.Security;
|
||||
|
||||
namespace Kreta.Web.Areas.Intezmeny.ApiControllers
|
||||
{
|
||||
[ApiRoleClaimsAuthorize(true)]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public class IntezmenyApiController : ApiController
|
||||
{
|
||||
private readonly IJiraHelper JiraHelper;
|
||||
|
||||
public IntezmenyApiController(IJiraHelper jiraHelper)
|
||||
{
|
||||
JiraHelper = jiraHelper ?? throw new ArgumentNullException(nameof(jiraHelper));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue, KretaClaimPackages.Ellenorzo.ClaimValue)]
|
||||
public IntezmenyModel GetIntezmeny(IIktatoRepositoryFactory iktatoRepositoryFactory, IktatoServiceConfiguration iktatoServiceConfiguration)
|
||||
{
|
||||
IntezmenyModel model = new IntezmenyModel();
|
||||
|
||||
var helper = new IntezmenyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
IntezmenyCO co = helper.GetIntezmenyiAdatok();
|
||||
|
||||
if (co != null)
|
||||
{
|
||||
var posziHelper = new PoszeidonHelper(ConnectionTypeExtensions.GetSessionConnectionType(), iktatoRepositoryFactory, iktatoServiceConfiguration);
|
||||
|
||||
var dokumentumCO = posziHelper.IntezmenyiKotelezoDokumentum(null, DokumentumTipusEnum.AlapitoOkirat);
|
||||
co.AlapitoOkirat = dokumentumCO;
|
||||
dokumentumCO = posziHelper.IntezmenyiKotelezoDokumentum(null, DokumentumTipusEnum.SzervezetiEsMukodesiSzabalyzat);
|
||||
co.SzervezetiEsMukodesiSzabalyzat = dokumentumCO;
|
||||
dokumentumCO = posziHelper.IntezmenyiKotelezoDokumentum(null, DokumentumTipusEnum.PedagogiaiProgram);
|
||||
co.PedagogiaiProgram = dokumentumCO;
|
||||
dokumentumCO = posziHelper.IntezmenyiKotelezoDokumentum(null, DokumentumTipusEnum.Hazirend);
|
||||
co.Hazirend = dokumentumCO;
|
||||
dokumentumCO = posziHelper.IntezmenyiKotelezoDokumentum(ClaimData.SelectedTanevID, DokumentumTipusEnum.Munkaterv);
|
||||
co.Munkaterv = dokumentumCO;
|
||||
dokumentumCO = posziHelper.IntezmenyiKotelezoDokumentum(null, DokumentumTipusEnum.mukodesi_engedely);
|
||||
co.MukodesiEngedely = dokumentumCO;
|
||||
|
||||
model = ConvertIntezmenyCoToModel(co);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue, KretaClaimPackages.Ellenorzo.ClaimValue)]
|
||||
public DataSourceResult GetIntezmenyMukodesiHelyGrid(string data, [System.Web.Http.ModelBinding.ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
MukodesiHelyHelper helper = new MukodesiHelyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
var helyek = helper.GetMukodesiHelyek();
|
||||
|
||||
return helyek.ToDataSourceResult();
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue, KretaClaimPackages.Ellenorzo.ClaimValue)]
|
||||
public DataSourceResult GetIntezmenyFeladatEllatasiHelyGrid(string id, [System.Web.Http.ModelBinding.ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
FeladatEllatasiHelyHelper helper = new FeladatEllatasiHelyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
|
||||
var ds = helper.GetFeladatEllatasiHelyByMukodesiHelyID(int.Parse(id));
|
||||
return ds.ToDataSourceResult();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveIntezmeny(IntezmenyModel pmodel)
|
||||
{
|
||||
bool isNevOmKodModosithato = ApplicationData.SystemType == SystemType.AZURE || ApplicationData.SystemType == SystemType.NSZFH_EMA;
|
||||
|
||||
if (IsOMKodValid(pmodel.OMKod) == false && isNevOmKodModosithato)
|
||||
{
|
||||
ModelState.AddModelError("OMKod", StringResourcesUtil.GetString(4483) /*Az OM kódnak 6 számjegyűnek kell lennie!*/);
|
||||
}
|
||||
|
||||
if (!pmodel.Telefon.IsValidPhone())
|
||||
{
|
||||
ModelState.AddModelError("Telefon", ErrorResource.ATelefonszamFormatumaNemMegfelelo);
|
||||
}
|
||||
|
||||
if (ClaimData.IsKretaAdministrator)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(pmodel.AdminEmail))
|
||||
{
|
||||
ModelState.AddModelError("AdminEmail", string.Format(ErrorResource.Required, CommonResource.AdminEmail));
|
||||
}
|
||||
else if (!pmodel.AdminEmail.IsValidEmail())
|
||||
{
|
||||
ModelState.AddModelError("AdminEmail", ErrorResource.EMailCimFormatumaNemMegfelelo);
|
||||
}
|
||||
}
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var helper = new IntezmenyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
if (ClaimData.IsKretaAdministrator)
|
||||
{
|
||||
JiraHelper.ChangeAdminEmail(ClaimData.IntezmenyAzonosito, pmodel.AdminEmail);
|
||||
}
|
||||
|
||||
IntezmenyCO co = ConvertIntezmenyModelToCo(pmodel, isNevOmKodModosithato);
|
||||
helper.SaveIntezmenyiAdatok(co, isNevOmKodModosithato, ClaimData.IsKretaAdministrator);
|
||||
|
||||
ClaimData.OrganizationShortName = co.RovidNev;
|
||||
ClaimData.OrganizationCode = co.OMKod;
|
||||
ClaimData.RefreshOrganizationFullAddress(co);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveMukodesiHely(MukodesiHelyModel pmodel)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (pmodel.MukodesiHelyTipusa.HasValue && pmodel.MukodesiHelyTipusa.Value == (int)MukodesiHelyTipusEnum.Telephely && !pmodel.TelephelyAnyaintezmeny.HasValue)
|
||||
{
|
||||
ModelState.AddModelError(nameof(pmodel.TelephelyAnyaintezmeny), IntezmenyResource.TelephelyAnyaIntezmenyKotelezo);
|
||||
}
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
MukodesiHelyHelper helper = new MukodesiHelyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
if (pmodel.MukodesiHelyTipusa != null && (MukodesiHelyTipusEnum)pmodel.MukodesiHelyTipusa == MukodesiHelyTipusEnum.Szekhely)
|
||||
{
|
||||
bool vanMasikSzekhely;
|
||||
if (!pmodel.Id.HasValue)
|
||||
{
|
||||
var mukodesiHelyek = helper.GetMukodesiHelyek()
|
||||
.Tables[0]
|
||||
.Rows.Cast<DataRow>().ToList();
|
||||
|
||||
vanMasikSzekhely = mukodesiHelyek
|
||||
.Any(CheckSzekhely(pmodel));
|
||||
}
|
||||
else
|
||||
{
|
||||
var mukodesiHelyek = helper.GetMukodesiHelyek()
|
||||
.Tables[0]
|
||||
.Rows.Cast<DataRow>();
|
||||
|
||||
vanMasikSzekhely = mukodesiHelyek
|
||||
.Any(CheckSzekhely(pmodel));
|
||||
}
|
||||
|
||||
if (vanMasikSzekhely)
|
||||
{
|
||||
ModelState.AddModelError(nameof(pmodel.MukodesiHelyTipusa), IntezmenyResource.CsakEgySzekhelyLehet);
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
}
|
||||
|
||||
if (pmodel.MukodesiHelyTipusa.HasValue && pmodel.MukodesiHelyTipusa.Value != (int)MukodesiHelyTipusEnum.Tagintezmeny)
|
||||
{
|
||||
pmodel.VezetoNeve = string.Empty;
|
||||
}
|
||||
|
||||
var co = pmodel.ToCo();
|
||||
if (helper.MukodesiHelyAzonositoExists(co))
|
||||
{
|
||||
ModelState.AddModelError(nameof(pmodel.MukodesiHelyAzonosito), ErrorResource.AMegadottMukodesiHelyAzonositoMarLetezik);
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
|
||||
helper.SaveMukodesiHely(co);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
catch (SDA.DataProvider.SDADataProviderException ex)
|
||||
{
|
||||
if (ex.Error == SDA.DataProvider.SDADataProviderError.UniqueKeyViolation)
|
||||
{
|
||||
ModelState.AddModelError(nameof(pmodel.Nev), ErrorResource.IlyenNevuMukodesiHelyMarLetezik);
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
catch (CannotBeInsertedException ex)
|
||||
{
|
||||
ModelState.AddModelError(nameof(pmodel.MukodesiHelyAzonosito), ex.Message);
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public MukodesiHelyModel GetMukodesiHely([FromBody] int pId)
|
||||
{
|
||||
var helper = new MukodesiHelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
MukodesiHelyCO co = helper.GetMukodesiHelyAdatok(pId);
|
||||
return new MukodesiHelyModel(co);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SaveFeladat(FeladatellatasiHelyModel pmodel)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var helper = new FeladatEllatasiHelyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
if (!string.IsNullOrWhiteSpace(pmodel.KIRFeladatellatasiHelySorszama))
|
||||
{
|
||||
pmodel.KIRFeladatellatasiHelySorszama = pmodel.KIRFeladatellatasiHelySorszama.Replace("_", string.Empty);
|
||||
|
||||
if (!Regex.IsMatch(pmodel.KIRFeladatellatasiHelySorszama, Core.Constants.RegularExpressions.KIRFeladatellatasiHelySorszama))
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.KIRFeladatellatasiHelySorszamCsak3JegyuSzamLehet);
|
||||
}
|
||||
}
|
||||
|
||||
var co = ConvertFeladatellatasiHelyModelToCo(pmodel);
|
||||
try
|
||||
{
|
||||
helper.SaveFeladatEllatasiHelyAdatok(co);
|
||||
}
|
||||
catch (BlException blex)
|
||||
{
|
||||
|
||||
throw new StatusError(HttpStatusCode.BadRequest, blex.Message);
|
||||
}
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteMukodesiHely([FromBody] int pID)
|
||||
{
|
||||
try
|
||||
{
|
||||
MukodesiHelyHelper helper = new MukodesiHelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
helper.DeleteMukodesiHely(pID);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (CannotBeDeletedException ex)
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ex.Message);
|
||||
}
|
||||
catch (EntityDeleteFailedException ex)
|
||||
{
|
||||
var uzenet = string.Format(ErrorResource.NemTorolhetoKapcsolatMiatt, IntezmenyResource.MukodesiHely, ex.ConnectionErrorMessage);
|
||||
throw new StatusError(HttpStatusCode.BadRequest, uzenet);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage DeleteFeladat([FromBody] int pID)
|
||||
{
|
||||
try
|
||||
{
|
||||
FeladatEllatasiHelyHelper helper = new FeladatEllatasiHelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
helper.FeladatEllatasiHelyTorles(pID);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch (EntityDeleteFailedException ex)
|
||||
{
|
||||
var errorMessage = string.Format(ErrorResource.NemTorolhetoKapcsolatMiatt, CommonResource.Feladatellatasihely, ex.ConnectionErrorMessage);
|
||||
|
||||
throw new StatusError(HttpStatusCode.BadRequest, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public FeladatellatasiHelyModel GetFeladatellatasiHely([FromBody] int pfeladatellatasiHelyId)
|
||||
{
|
||||
FeladatellatasiHelyModel model = new FeladatellatasiHelyModel();
|
||||
|
||||
var helper = new FeladatEllatasiHelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
FeladatEllatasiHelyCO co = helper.GetFeladatEllatasiHelyAdatok(pfeladatellatasiHelyId);
|
||||
if (co != null)
|
||||
{
|
||||
model = ConvertFeladatellatasiHelyCoToModel(co);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public List<System.Web.Mvc.SelectListItem> GetFeladatListByMukodesiHelyId([FromBody] int pmukodesiHelyId)
|
||||
{
|
||||
var helper = new FeladatEllatasiHelyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
var feladatIdList = helper.GetGetFeladatEllatasiHelyIdListByMukodesiHelyID(pmukodesiHelyId);
|
||||
|
||||
var feladatDDLDataSource = ((int)GeneratedAdatszotarTipusEnum.OktatasiNevelesiFeladat).GetItemsByType(ClaimData.SelectedTanevID.Value, true).ToSelectItemList();
|
||||
|
||||
foreach (var id in feladatIdList)
|
||||
{
|
||||
feladatDDLDataSource.RemoveAll(i => i.Value == id.ToString());
|
||||
}
|
||||
|
||||
return feladatDDLDataSource;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ApiValidateAjaxAntiForgeryToken]
|
||||
public HttpResponseMessage SetSzekhely([FromBody] int pmukodesiHelyId)
|
||||
{
|
||||
var helper = new MukodesiHelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
helper.SetSzekhely(pmukodesiHelyId);
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public FeladatellatasiHelyModel GetFeladatellatasiHelyAlapadatok(int feladellHelyID)
|
||||
{
|
||||
var helper = new FeladatEllatasiHelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
var co = helper.GetFeladatEllatasiHelyAdatok(feladellHelyID);
|
||||
var model = new FeladatellatasiHelyModel();
|
||||
|
||||
model.ID = co.ID;
|
||||
model.MukodesiHelyNev = co.MukodesiHelyNev;
|
||||
model.FeladatTipusNev = co.OktatasiNevelesiFeladatNev;
|
||||
|
||||
return model;
|
||||
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public DataSourceResult GetFeladatellatasiHelyOsztalycsoportjai(string id, [System.Web.Http.ModelBinding.ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var helper = new FeladatEllatasiHelyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
|
||||
var ds = helper.GetFeladatellatasiHelyOsztalycsoportjai(SDAConvert.ToInt32(id));
|
||||
|
||||
return ds.ToDataSourceResult();
|
||||
}
|
||||
|
||||
[ApiRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public DataSourceResult GetFeladatellatasiHelyAlkalmazottjai(string id, [System.Web.Http.ModelBinding.ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
|
||||
{
|
||||
var helper = new FeladatEllatasiHelyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
helper.GridParameters = Converter.GridParameter(request);
|
||||
|
||||
var ds = helper.GetFeladatellatasiHelyAlkalmazottjai(SDAConvert.ToInt32(id));
|
||||
|
||||
return ds.ToDataSourceResult();
|
||||
}
|
||||
|
||||
public IntezmenyiDokumentumModel GetIntezmenyiDokumentumModel(Enums.DokumentumTipusEnum dokumentumTipus, IIktatoRepositoryFactory
|
||||
iktatoRepositoryFactory, IktatoServiceConfiguration iktatoServiceConfiguration)
|
||||
{
|
||||
var helper = new PoszeidonHelper(ConnectionTypeExtensions.GetSessionConnectionType(), iktatoRepositoryFactory, iktatoServiceConfiguration);
|
||||
|
||||
var co = helper.IntezmenyiKotelezoDokumentum((dokumentumTipus != Enums.DokumentumTipusEnum.Munkaterv) ? null : ClaimData.SelectedTanevID, dokumentumTipus);
|
||||
return ConvertIntezmenyiDokumentumCoToModel(co);
|
||||
}
|
||||
|
||||
#region Others
|
||||
private IntezmenyModel ConvertIntezmenyCoToModel(IntezmenyCO co)
|
||||
{
|
||||
IntezmenyModel model = new IntezmenyModel()
|
||||
{
|
||||
Email = co.Email,
|
||||
AdminEmail = co.AdminEmail,
|
||||
Id = co.ID,
|
||||
IgazgatoNeve = co.Igazgato,
|
||||
IntezmenyNev = co.Nev,
|
||||
OMKod = co.OMKod,
|
||||
RovidNev = co.RovidNev,
|
||||
Telefon = co.Telefonszam,
|
||||
EngedelyezettAllashely = co.EngedelyezettAllashely ?? 0,
|
||||
Orszag = co.Orszag,
|
||||
Iranyitoszam = co.Iranyitoszam,
|
||||
Iranyitoszam_Str = co.Iranyitoszam,
|
||||
HelysegNev = co.Varos,
|
||||
HelysegNev_Str = co.Varos,
|
||||
KozteruletTipus = co.KozteruletJellegNev,
|
||||
KozteruletTipus_Str = co.KozteruletJellegNev,
|
||||
KozteruletNev = co.Kozterulet,
|
||||
Emelet = co.Emelet,
|
||||
Hazszam = co.Hazszam,
|
||||
Ajto = co.Ajto,
|
||||
IsSzakkepzo = co.IsSzakkepzo,
|
||||
JuttatasHatarnap = co.JuttatasHatarnap - 1,
|
||||
};
|
||||
|
||||
model.AlapitoOkirat = ConvertIntezmenyiDokumentumCoToModel(co.AlapitoOkirat);
|
||||
model.SZMSZ = ConvertIntezmenyiDokumentumCoToModel(co.SzervezetiEsMukodesiSzabalyzat);
|
||||
model.PedagogiaiProgram = ConvertIntezmenyiDokumentumCoToModel(co.PedagogiaiProgram);
|
||||
model.Hazirend = ConvertIntezmenyiDokumentumCoToModel(co.Hazirend);
|
||||
model.Munkaterv = ConvertIntezmenyiDokumentumCoToModel(co.Munkaterv);
|
||||
model.MukodesiEngedely = ConvertIntezmenyiDokumentumCoToModel(co.MukodesiEngedely);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private IntezmenyCO ConvertIntezmenyModelToCo(IntezmenyModel model, bool isNevOMKodModosithato)
|
||||
{
|
||||
IntezmenyCO co = new IntezmenyCO()
|
||||
{
|
||||
Email = model.Email,
|
||||
AdminEmail = model.AdminEmail,
|
||||
ID = model.Id ?? (int)default,
|
||||
Igazgato = model.IgazgatoNeve,
|
||||
RovidNev = model.RovidNev,
|
||||
Telefonszam = model.Telefon,
|
||||
EngedelyezettAllashely = model.EngedelyezettAllashely.HasValue ? model.EngedelyezettAllashely : 0,
|
||||
Orszag = model.Orszag,
|
||||
Iranyitoszam = model.Iranyitoszam_Str,
|
||||
Varos = model.HelysegNev_Str,
|
||||
Kozterulet = model.KozteruletNev,
|
||||
KozteruletJellegNev = model.KozteruletTipus_Str,
|
||||
Emelet = model.Emelet,
|
||||
Hazszam = model.Hazszam,
|
||||
Ajto = model.Ajto,
|
||||
IsSzakkepzo = model.IsSzakkepzo,
|
||||
JuttatasHatarnap = model.JuttatasHatarnap + 1,
|
||||
};
|
||||
|
||||
if (isNevOMKodModosithato)
|
||||
{
|
||||
co.Nev = model.IntezmenyNev;
|
||||
co.OMKod = model.OMKod;
|
||||
}
|
||||
|
||||
if (model.AlapitoOkirat != null)
|
||||
{
|
||||
co.AlapitoOkirat = ConvertIntezmenyiDokumentumModelToCo(model.AlapitoOkirat);
|
||||
}
|
||||
if (model.SZMSZ != null)
|
||||
{
|
||||
co.SzervezetiEsMukodesiSzabalyzat = ConvertIntezmenyiDokumentumModelToCo(model.SZMSZ);
|
||||
}
|
||||
if (model.PedagogiaiProgram != null)
|
||||
{
|
||||
co.PedagogiaiProgram = ConvertIntezmenyiDokumentumModelToCo(model.PedagogiaiProgram);
|
||||
}
|
||||
if (model.Hazirend != null)
|
||||
{
|
||||
co.Hazirend = ConvertIntezmenyiDokumentumModelToCo(model.Hazirend);
|
||||
}
|
||||
if (model.Munkaterv != null)
|
||||
{
|
||||
co.Munkaterv = ConvertIntezmenyiDokumentumModelToCo(model.Munkaterv);
|
||||
}
|
||||
if (model.MukodesiEngedely != null)
|
||||
{
|
||||
co.MukodesiEngedely = ConvertIntezmenyiDokumentumModelToCo(model.MukodesiEngedely);
|
||||
}
|
||||
|
||||
return co;
|
||||
}
|
||||
|
||||
private FeladatellatasiHelyModel ConvertFeladatellatasiHelyCoToModel(FeladatEllatasiHelyCO co)
|
||||
{
|
||||
FeladatellatasiHelyModel model = new FeladatellatasiHelyModel()
|
||||
{
|
||||
FeladatTipus = co.OktatasiNevelesiFeladat.Value,
|
||||
ID = co.ID,
|
||||
MukodesiHelyID = co.MukodesiHelyID,
|
||||
KIRFeladatellatasiHelySorszama = co.KIRFeladatellatasiHelySorszama
|
||||
};
|
||||
|
||||
return model;
|
||||
}
|
||||
private FeladatEllatasiHelyCO ConvertFeladatellatasiHelyModelToCo(FeladatellatasiHelyModel model)
|
||||
{
|
||||
FeladatEllatasiHelyCO co = new FeladatEllatasiHelyCO()
|
||||
{
|
||||
OktatasiNevelesiFeladat = model.FeladatTipus,
|
||||
ID = model.ID,
|
||||
MukodesiHelyID = model.MukodesiHelyID,
|
||||
KIRFeladatellatasiHelySorszama = model.KIRFeladatellatasiHelySorszama,
|
||||
TanevId = ClaimData.SelectedTanevID.Value
|
||||
};
|
||||
|
||||
return co;
|
||||
}
|
||||
|
||||
private IntezmenyiDokumentumModel ConvertIntezmenyiDokumentumCoToModel(IntezmenyiDokumentumCO co)
|
||||
{
|
||||
return new IntezmenyiDokumentumModel()
|
||||
{
|
||||
Nev = co.Nev,
|
||||
Tipus = co.Tipus,
|
||||
FajlNev = co.FajlNev,
|
||||
Statusz = co.Statusz,
|
||||
IktatottDokumentumId = co.IktatottDokumentumId
|
||||
};
|
||||
}
|
||||
|
||||
private IntezmenyiDokumentumCO ConvertIntezmenyiDokumentumModelToCo(IntezmenyiDokumentumModel model)
|
||||
{
|
||||
return new IntezmenyiDokumentumCO()
|
||||
{
|
||||
Nev = model.Nev,
|
||||
Tipus = model.Tipus,
|
||||
FajlNev = model.FajlNev,
|
||||
Statusz = model.Statusz,
|
||||
IktatottDokumentumId = model.IktatottDokumentumId
|
||||
};
|
||||
}
|
||||
|
||||
private bool IsOMKodValid(string omKod)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(omKod) && Regex.IsMatch(omKod, Core.Constants.RegularExpressions.OMAzonosito);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PrivateMethods
|
||||
|
||||
/// <summary>
|
||||
/// Can be used as the evaluator for iterating through the list of MukodesiHely-s within an Any function to check if there is already a Szekhely which is not the one currently being edited.
|
||||
/// </summary>
|
||||
/// <param name="pmodel">MukodesiHely currently being edited.</param>
|
||||
/// <returns></returns>
|
||||
private Func<DataRow, bool> CheckSzekhely(MukodesiHelyModel pmodel)
|
||||
{
|
||||
return row =>
|
||||
{
|
||||
MukodesiHelyTipusEnum castedValue;
|
||||
var successParse = Enum.TryParse(row["C_MUKODESIHELYTIPUSA"]?.ToString(), out castedValue);
|
||||
|
||||
if (successParse && castedValue == MukodesiHelyTipusEnum.Szekhely)
|
||||
{
|
||||
if (pmodel.Id.HasValue && row["ID"]?.ToString() == pmodel.Id.Value.ToString())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue