using Neo.Afx.Mvc; using Neo.Afx.Services.Integration; using Neo.Afx.Services.Workflows; using Neo.Afx.ViewModels; using Neo.LegitimateLicences.Common; using Neo.LegitimateLicences.Common.Helpers; using Neo.LegitimateLicences.Data.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Neo.LegitimateLicences.Associations { public partial class AssociationsController : Neo.LegitimateLicences.Common.ControllerBase { #region Action Results #region Default public ActionResult Default() { if (!SecurityHelper.UserHasAccessToSecurable(Profile.Securables.ToList(), Common.SecurableEnum.AssociationsModule)) { return RedirectToAction("Default", "Applications"); } var model = new DefaultModel { Associations = new List(), Lookups = GetLookups() }; WebHelper.SetLastPageVisited(HttpContext, "Associations/Default"); ViewBag.Controller = "Associations"; ViewBag.Page = "Home"; return View("Default", model); } #endregion #endregion #region JSON endpoints [HttpPost] public JsonResult SearchVerifiedAssociations(long? regionIdSearch, string associationNameSearch) { var database = new LegitimateDatabase(); IEnumerable data = new List(); var success = true; var errorMessage = ""; try { data = database.SearchVerifiedAssociations(regionIdSearch, associationNameSearch, Profile.UserID); } catch (Exception ex) { success = false; errorMessage = database.GetInnermostMessage(ex); } return Json(new { data, success, errorMessage }, JsonSerializerOptions.None); } #endregion #region GetLookups public List GetLookups() { var lookups = new List(); var database = new LegitimateDatabase(); var integrationStore = new SqlIntegrationStore(); try { integrationStore.Open(); lookups.Add(new LookupList("Regions", integrationStore.GetDataEntities("Regions", string.Empty).OrderBy(a => a.Title))); } finally { integrationStore.Close(); } return lookups; } #endregion } }