using System.Web.Mvc; using Neo.Legitimate.Applications.Models; using Neo.Legitimate.Data.Models; using Pilotfish.Afx.Mvc; using Neo.Legitimate.Common; using System; using System.Linq; namespace Neo.Legitimate.Applications.Controllers { public partial class ApplicationsController : Neo.Legitimate.Common.ControllerBase { #region Action Results #region PurificationAllowedNewLicences public ActionResult PurificationAllowedNewLicences() { if (!SecurityHelper.UserHasAccessToSecurable(Profile.Securables.ToList(), Securable.ApplicationsModule_Purification_Manageallowednewlicencelist)) { return RedirectToAction("Default", "Applications"); } var database = new LegitimateDatabase(); var model = new PurificationAllowedNewLicencesModel { AllowedNewLicences = database.GetAllowedNewLicences() }; ViewBag.Controller = "Applications"; ViewBag.Page = "PurificationAllowedNewLicences"; return View("PurificationAllowedNewLicences", model); } #endregion #endregion #region JSON endpoints [HttpPost] public JsonResult SaveAllowedNewLicence(long applicationAllowedNewLicenceID, long associationID, string memberName, string idNumber, string registrationNumber, short applicationAllowedNewLicenceTypeID, string operatingLicenceNumber, string applicationReferenceNumber) { if (!SecurityHelper.UserHasAccessToSecurable(Profile.Securables.ToList(), Securable.ApplicationsModule_Purification_Manageallowednewlicencelist)) { throw new Exception("Security error"); } var errorMessage = ""; var success = false; var database = new LegitimateDatabase(); try { database.Purification_InsertAllowedNewLicence(applicationAllowedNewLicenceID, associationID, memberName, idNumber, registrationNumber, applicationAllowedNewLicenceTypeID, operatingLicenceNumber, applicationReferenceNumber, Profile.UserID); success = true; } catch (Exception ex) { errorMessage = database.GetInnermostMessage(ex); } var results = new { Success = success, ErrorMessage = errorMessage }; return Json(results, JsonSerializerOptions.None); } #endregion } }