using System.Web.Mvc; using Neo.Legitimate.InspectionConsole.Models; using Neo.Legitimate.Data.Models; using Pilotfish.Afx.Mvc; using System; namespace Neo.Legitimate.InspectionConsole.Controllers { [Authorize] public class InspectionConsoleController : Neo.Legitimate.Common.ControllerBase { private const long _entityID = 1014; private const long _documentStoreLocationID = 3; #region Action Results #region Default public ActionResult Default(long licenceIssueDetailID) { var database = new LegitimateDatabase(); var inspection = database.GetInspectionDetail(licenceIssueDetailID); var model = new DefaultModel { InspectionDetail = inspection, Application = database.GetApplicationRequestDetail_ViewOnly(inspection.LicenceIssueDetail.ApplicationRequestDetailID), entityID = _entityID, itemID = licenceIssueDetailID, DocumentStoreLocationID = _documentStoreLocationID, Outcomes = database.GetInspectionOutcomes() }; ViewBag.Controller = "Inspection Details"; ViewBag.Page = "Inspection Details"; model.InspectionDetail.DateInspected = DateTime.Now; return View("Default", model); } #endregion #endregion #region JSON endpoints // All JSON endpoints require [HttpPost] to prevent JSON hijacking. // With [HttpPost], returning arrays is allowed. // See http://haacked.com/archive/2009/06/25/json-hijacking.aspx [HttpPost] public JsonResult Save(LicenceIssueInspectionDetail detail) { var database = new LegitimateDatabase(); var errorMessage = ""; var success = database.SaveInspectionDetail(detail, Profile.UserID, out errorMessage); var results = new { Success = success, ErrorMessage = errorMessage }; return Json(results, JsonSerializerOptions.None); } #endregion } }