Need DB
This commit is contained in:
		
							
								
								
									
										43
									
								
								Server/ApiControllers/PinController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								Server/ApiControllers/PinController.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
|  | ||||
| namespace OI.Metrology.Server.ApiControllers; | ||||
|  | ||||
| using OI.Metrology.Shared.Models.Stateless; | ||||
| using System.Text.Json; | ||||
|  | ||||
| [Route("api/[controller]")] | ||||
| 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; | ||||
|     } | ||||
|  | ||||
|     [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); | ||||
|         return Ok(); | ||||
|     } | ||||
|  | ||||
|     [HttpGet] | ||||
|     [Route("{id}/pinned")] | ||||
|     public IActionResult GetPinnedTable(int id) | ||||
|     { | ||||
|         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, bioRad, cde), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user