141 lines
5.4 KiB
C#
141 lines
5.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using Kreta.BusinessLogic.HelperClasses;
|
|
using Kreta.BusinessLogic.Helpers;
|
|
using Kreta.BusinessLogic.Security;
|
|
using Kreta.BusinessLogic.Utils;
|
|
using Kreta.Core;
|
|
using Kreta.Core.FileService;
|
|
using Kreta.Enums;
|
|
using Kreta.Framework.Util;
|
|
using Kreta.Web.Areas.Adatszolgaltatasok.Models;
|
|
using Kreta.Web.Helpers;
|
|
using Kreta.Web.Models.EditorTemplates;
|
|
using Kreta.Web.Security;
|
|
|
|
namespace Kreta.Web.Areas.Adatszolgaltatasok.Controllers
|
|
{
|
|
[MvcRoleClaimsAuthorize(true)]
|
|
[MvcRolePackageDenyAuthorize(KretaClaimPackages.IsOnlyAlkalmozott.ClaimValue)]
|
|
[MvcRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
|
public class MerohelyController : Controller
|
|
{
|
|
private readonly IFileService _fileService;
|
|
|
|
public MerohelyController(IFileService fileService)
|
|
{
|
|
_fileService = fileService;
|
|
}
|
|
|
|
// GET: Adatszolgaltatasok/KozmuAdatok
|
|
public ActionResult Index()
|
|
{
|
|
MerohelySearchModel model = new MerohelySearchModel();
|
|
return View("Index", model);
|
|
}
|
|
|
|
public ActionResult OpenMerohelyPopup(int? id)
|
|
{
|
|
bool isModify = id.IsEntityId();
|
|
MerohelyModel merohelyModel;
|
|
if (isModify)
|
|
{
|
|
MerohelyCO co = new MerohelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).GetMerohelyById(id.Value);
|
|
merohelyModel = new MerohelyModel
|
|
{
|
|
Id = co.Id.Value,
|
|
Nev = co.Nev,
|
|
MeroallasFrissiteseSzukseges = co.MeroallasFrissiteseSzukseges,
|
|
MerohelyTipusId = co.MerohelyTipusId,
|
|
MukodesiHelyId = co.MukodesiHelyId,
|
|
MerohelyTipusList = GetMerohelyTipusListList(),
|
|
MukodesiHelyList = GetMukodesiHelyList()
|
|
};
|
|
}
|
|
else
|
|
{
|
|
merohelyModel = new MerohelyModel
|
|
{
|
|
Nev = "",
|
|
MerohelyTipusId = (int)MerohelyTipusEnum.Egyeb,
|
|
MerohelyTipusList = GetMerohelyTipusListList(),
|
|
MukodesiHelyList = GetMukodesiHelyList()
|
|
};
|
|
}
|
|
|
|
var popupModel = new PopUpModel(merohelyModel, "New_Modify_Merohely_Popup");
|
|
popupModel.AddCancelBtn(popupModel, "MerohelyHelper.MerohelyPopupCancel");
|
|
popupModel.AddOkBtn(popupModel, "MerohelyHelper.MerohelyPopupSave");
|
|
|
|
return PartialView(Constants.General.PopupView, popupModel);
|
|
}
|
|
|
|
public ActionResult GetMerohelyDetailGrid(MerohelyGridModel merohely)
|
|
{
|
|
return PartialView("Merohely_DetailGrid", merohely);
|
|
}
|
|
|
|
private List<SelectListItem> GetMukodesiHelyList()
|
|
{
|
|
MukodesiHelyHelper helper = new MukodesiHelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
|
|
|
return helper.GetMukodesiHelyekDDL(string.Empty).OrderBy(x => x.Value).ToDictionary(k => k.Key, v => v.Value).ToSelectItemList();
|
|
}
|
|
|
|
private List<SelectListItem> GetMerohelyTipusListList()
|
|
=> ((int)GeneratedAdatszotarTipusEnum.MerohelyTipus).GetItemsByType(ClaimData.SelectedTanevID.Value, true).ToSelectItemList();
|
|
|
|
public ActionResult OpenMeroallasPopup(int? id, int merohelyId)
|
|
{
|
|
bool isModify = id.IsEntityId();
|
|
MeroallasModel meroallasModel;
|
|
if (isModify)
|
|
{
|
|
MeroallasCO co = new MerohelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).GetMeroallasById(id.Value);
|
|
|
|
meroallasModel = new MeroallasModel
|
|
{
|
|
Id = co.Id.Value,
|
|
MerohelyId = co.MerohelyId,
|
|
Meroallas = co.MeroallasErtek,
|
|
LeolvasasDatuma = co.LeolvasasDatuma,
|
|
PictureId = co.KepId
|
|
};
|
|
}
|
|
else
|
|
{
|
|
meroallasModel = new MeroallasModel
|
|
{
|
|
Id = default(int),
|
|
MerohelyId = merohelyId,
|
|
LeolvasasDatuma = DateTime.UtcNow
|
|
};
|
|
}
|
|
|
|
var popupModel = new PopUpModel(meroallasModel, "New_Modify_Meroallas_Popup");
|
|
popupModel.AddCancelBtn(popupModel, "MerohelyHelper.MeroallasPopupCancel");
|
|
popupModel.AddOkBtn(popupModel, "MerohelyHelper.MeroallasPopupSave");
|
|
|
|
return PartialView(Constants.General.PopupView, popupModel);
|
|
}
|
|
|
|
public ActionResult OpenMeroallasImagePopup(int id)
|
|
{
|
|
MeroallasImageModel meroallasImageModel = new MeroallasImageModel();
|
|
|
|
var picture = new MerohelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).GetPicture(_fileService, id);
|
|
if (picture != null)
|
|
{
|
|
meroallasImageModel.Name = picture.Name;
|
|
meroallasImageModel.ContentAsBase64EncodedString = picture.ContentAsBase64EncodedString;
|
|
}
|
|
|
|
var popupModel = new PopUpModel(meroallasImageModel, "MeroallasImage_Popup");
|
|
popupModel.AddCancelBtn(popupModel, "MerohelyHelper.MeroallasImage_PopupCancel");
|
|
|
|
return PartialView(Constants.General.PopupView, popupModel);
|
|
}
|
|
}
|
|
}
|