Removed HttpContext.Session

This commit is contained in:
2023-02-09 22:58:49 -07:00
parent 4514678556
commit 2481c2b3ff
6 changed files with 124 additions and 138 deletions

View File

@ -9,13 +9,11 @@ using System.Text.Json;
public class PinController : Controller, IPinController<IActionResult>
{
private readonly ILogger _Logger;
private readonly IPinRepository _PinRepository;
private readonly IMetrologyRepository _MetrologyRepository;
public PinController(ILogger<InboundController> logger, IMetrologyRepository metrologyRepository, IPinRepository pinRepository)
{
_Logger = logger;
_MetrologyRepository = metrologyRepository;
_PinRepository = pinRepository;
}
@ -23,23 +21,13 @@ public class PinController : Controller, IPinController<IActionResult>
[HttpPost("/api/pin/markAsPinned")]
public IActionResult MarkAsPinned(Shared.DataModels.HeaderCommon headerCommon)
{
string toolTypeId = headerCommon.ToolTypeID.ToString();
string json = JsonSerializer.Serialize(headerCommon, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
string? was = HttpContext.Session.GetString(toolTypeId);
if (was is not null)
_Logger.LogDebug($"{toolTypeId} was: {was}");
HttpContext.Session.SetString(toolTypeId, json);
_PinRepository.SetPinnedTable(headerCommon);
return Ok();
}
[HttpGet]
[Route("{id}/pinned/{rds}")]
public IActionResult GetPinnedTable(int id, string rds = "")
{
string? cde = HttpContext.Session.GetString(((int)IPinRepository.ToolId.CDE).ToString());
string? bioRad = HttpContext.Session.GetString(((int)IPinRepository.ToolId.BioRad).ToString());
return Json(_PinRepository.GetPinnedTable(_MetrologyRepository, id, rds, bioRad, cde), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
}
[Route("{id}/pinned")]
public IActionResult GetPinnedTable(int id, string? biorad_id = null, string? cde_id = null, string? rds = null) =>
Json(_PinRepository.GetPinnedTable(_MetrologyRepository, id, biorad_id, cde_id, rds), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
}