Viewer to Server
This commit is contained in:
77
Server/Controllers/PagesController.cs
Normal file
77
Server/Controllers/PagesController.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using OI.Metrology.Server.Models;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.ViewModels;
|
||||
|
||||
namespace OI.Metrology.Server.Controllers;
|
||||
|
||||
public class PagesController : Controller
|
||||
{
|
||||
|
||||
private readonly string _ApiUrl;
|
||||
private readonly bool _IsTestDatabase;
|
||||
private readonly IMetrologyRepository _MetrologyRepository;
|
||||
|
||||
public PagesController(AppSettings appSettings, IMetrologyRepository metrologyRepository)
|
||||
{
|
||||
_MetrologyRepository = metrologyRepository;
|
||||
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
|
||||
_ApiUrl = string.IsNullOrEmpty(appSettings.ApiUrl) ? Url.Content("~/") : appSettings.ApiUrl[0] == '~' ? Url.Content(appSettings.ApiUrl) : appSettings.ApiUrl;
|
||||
}
|
||||
|
||||
public override void OnActionExecuted(ActionExecutedContext context)
|
||||
{
|
||||
base.OnActionExecuted(context);
|
||||
ViewBag.IsTestDatabase = _IsTestDatabase;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
ViewBag.ApiUrl = _ApiUrl;
|
||||
return View("AwaitingDispo");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/AwaitingDispo")]
|
||||
[Route("/Metrology/AwaitingDispo")]
|
||||
public IActionResult AwaitingDispo()
|
||||
{
|
||||
ViewBag.ApiUrl = _ApiUrl;
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/RunInfo")]
|
||||
[Route("/Metrology/RunInfo")]
|
||||
public IActionResult RunInfo([FromQuery] int tooltypeid = 1, [FromQuery] int headerid = 0)
|
||||
{
|
||||
RunInfo m = new()
|
||||
{
|
||||
ToolTypeID = tooltypeid,
|
||||
HeaderID = headerid,
|
||||
HeaderAttachmentID = Guid.Empty,
|
||||
};
|
||||
if (headerid > 0)
|
||||
{
|
||||
m.HeaderAttachmentID = _MetrologyRepository.GetHeaderAttachmentID(tooltypeid, headerid);
|
||||
}
|
||||
ViewBag.ApiUrl = _ApiUrl;
|
||||
return View(m);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/RunHeaders")]
|
||||
[Route("/Metrology/RunHeaders")]
|
||||
public IActionResult RunHeaders()
|
||||
{
|
||||
ViewBag.ApiUrl = _ApiUrl;
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/Crash")]
|
||||
public IActionResult Crash() => throw new Exception("Test unhandled exception");
|
||||
}
|
Reference in New Issue
Block a user