using Neo.Afx.Services.Workflows; using Neo.LegitimateLicences.Common; using Neo.LegitimateLicences.Data.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Neo.Afx.ViewModels; using Neo.Afx.Services.Integration; using Neo.LegitimateLicences.Common.Helpers; using Neo.Afx.Mvc; using System.Dynamic; namespace Neo.LegitimateLicences.Purification.Controllers { public partial class PurificationController : Neo.LegitimateLicences.Common.ControllerBase { #region Action Results #region ApplicationAllowedNewLicences public ActionResult ApplicationAllowedNewLicences() { if (!SecurityHelper.UserHasAccessToSecurable(Profile.Securables.ToList(), Common.SecurableEnum.PurificationModule_Manageallowednewlicencelist)) { return RedirectToAction("Default", "Dashboard"); } var database = new LegitimateDatabase(); var model = new PurificationApplicationAllowedNewLicencesModel { ApplicationAllowedNewLicences = database.GetApplicationAllowedNewLicences(Profile.UserID), ApplicationAllowedNewLicence = new Pr_GetApplicationAllowedNewLicences_Result(), Lookups = GetApplicationAllowedNewLicenceTypesLookups() }; WebHelper.SetLastPageVisited(HttpContext, "Purification/ApplicationAllowedNewLicences"); ViewBag.Controller = "Purification"; ViewBag.Page = "ApplicationAllowedNewLicences"; return View("ApplicationAllowedNewLicences", model); } #endregion #endregion #region GetApplicationAllowedNewLicenceTypesLookups public List GetApplicationAllowedNewLicenceTypesLookups() { var lookups = new List(); var integrationStore = new SqlIntegrationStore(); try { integrationStore.Open(); lookups.Add(new LookupList("ApplicationAllowedNewLicenceTypes", integrationStore.GetDataEntities("ApplicationAllowedNewLicenceTypes", string.Empty).OrderBy(a => a.Title))); } finally { integrationStore.Close(); } return lookups; } #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(), SecurableEnum.PurificationModule_Manageallowednewlicencelist)) { throw new Exception("Security error"); } var errorMessage = ""; var success = false; var database = new LegitimateDatabase(); var data = new List(); try { database.Purification_InsertAllowedNewLicence(applicationAllowedNewLicenceID, associationID, memberName, idNumber, registrationNumber, applicationAllowedNewLicenceTypeID, operatingLicenceNumber, applicationReferenceNumber, Profile.UserID); data = database.GetApplicationAllowedNewLicences(Profile.UserID); success = true; } catch (Exception ex) { errorMessage = database.GetInnermostMessage(ex); } var results = new { Data = data, Success = success, ErrorMessage = errorMessage }; return Json(results, JsonSerializerOptions.None); } #endregion } }