using Microsoft.AspNetCore.Mvc; namespace OI.Metrology.Archive.ApiContollers; using OI.Metrology.Shared.Repositories; using System.Text.Json; // this controller is for the Awaiting Dispo functionality public class AwaitingDispoController : Controller { protected IMetrologyRepo _Repo; public AwaitingDispoController(IMetrologyRepo repo) => _Repo = repo; // returns the data to show in the Awaiting Dispo grid // marked no-cache, just-in-case since igniteUI automatically adds a query string parameter to prevent caching [HttpGet("/api/awaitingdispo")] [ResponseCache(NoStore = true)] public IActionResult Index() { var r = new { Results = _Repo.GetAwaitingDispo() }; return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); } // this endpoint is used to set the ReviewDate column, causing the header to no longer show in Awaiting Dispo [HttpPost("/api/awaitingdispo/markasreviewed")] public IActionResult MarkAsReviewed([FromQuery] long headerid, [FromQuery] int tooltypeid) { _ = _Repo.UpdateReviewDate(tooltypeid, headerid, false); return Ok(); } // this endpoint is used to clear the ReviewDate column, causing the header to show up again [HttpPost("/api/awaitingdispo/markasawaiting")] public IActionResult MarkAsAwaiting([FromQuery] long headerid, [FromQuery] int tooltypeid) { if (_Repo.UpdateReviewDate(tooltypeid, headerid, true) <= 1) return Ok(); else return StatusCode(444); } }