using System.Web.Mvc; using Neo.Legitimate.OperatingLicences.Models; using Neo.Legitimate.Data.Models; using Pilotfish.Afx.Mvc; using Neo.Legitimate.Common; using System.Linq; using Neo.Legitimate.Common.Helpers; namespace Neo.Legitimate.OperatingLicences.Controllers { [Authorize] public partial class OperatingLicencesController : Neo.Legitimate.Common.ControllerBase { #region Action Results #region Expiries public ActionResult Expiries() { if (!SecurityHelper.UserHasAccessToSecurable(Profile.Securables.ToList(), Common.Securable.OperatingLicencesModule_Expiries)) { return RedirectToAction("Default", "Applications"); } var database = new LegitimateDatabase(); var model = new ExpiriesModel { OverdueUpliftmentsCount = database.GetLicencesOverdueUpliftment().Count, UpcomingExpiriesCount = database.GetLicencesUpcomingExpiries().Count, ExpiredLicencesCount = database.GetLicencesExpiredInGracePeriod().Count }; WebHelper.SetLastPageVisited(HttpContext, "OperatingLicences/Expiries"); ViewBag.Controller = "Operating Licences"; ViewBag.Page = "Expiries"; return View("Expiries", model); } #endregion #endregion #region JSON endpoints #region GetOverdueUpliftments [HttpPost] public JsonResult GetOverdueUpliftments() { var database = new LegitimateDatabase(); var results = new { Records = database.GetLicencesOverdueUpliftment(), Success = true }; return Json(results, JsonSerializerOptions.None); } #endregion #region GetUpcomingExpiries [HttpPost] public JsonResult GetUpcomingExpiries() { var database = new LegitimateDatabase(); var results = new { Records = database.GetLicencesUpcomingExpiries(), Success = true }; return Json(results, JsonSerializerOptions.None); } #endregion #region GetExpiredLicences [HttpPost] public JsonResult GetExpiredLicences() { var database = new LegitimateDatabase(); var results = new { Records = database.GetLicencesExpiredInGracePeriod(), Success = true }; return Json(results, JsonSerializerOptions.None); } #endregion ////[HttpPost] ////public JsonResult SendUpcomingSmsReminder(string licenceIdCsv) ////{ //// var database = new LegitimateDatabase(); //// var errorMessage = ""; //// var success = database.SendUpcomingSmsReminder(licenceIdCsv, Profile.UserID, out errorMessage); //// var response = new //// { //// Success = success, //// ErrorMessage = errorMessage //// }; //// return Json(response, JsonSerializerOptions.FormatDateTime); ////} ////[HttpPost] ////public JsonResult SendExpiredSmsReminder(string licenceIdCsv) ////{ //// var database = new LegitimateDatabase(); //// var errorMessage = ""; //// var success = database.SendExpiredSmsReminder(licenceIdCsv, Profile.UserID, out errorMessage); //// var response = new //// { //// Success = success, //// ErrorMessage = errorMessage //// }; //// return Json(response, JsonSerializerOptions.FormatDateTime); ////} #endregion } }