79 lines
2.3 KiB
C#
79 lines
2.3 KiB
C#
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 bool _IsTestDatabase;
|
|
private readonly AppSettings _AppSettings;
|
|
private readonly IMetrologyRepository _MetrologyRepository;
|
|
|
|
public PagesController(AppSettings appSettings, IMetrologyRepository metrologyRepository)
|
|
{
|
|
_AppSettings=appSettings;
|
|
_MetrologyRepository = metrologyRepository;
|
|
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
|
|
}
|
|
|
|
public override void OnActionExecuted(ActionExecutedContext context)
|
|
{
|
|
base.OnActionExecuted(context);
|
|
ViewBag.IsTestDatabase = _IsTestDatabase;
|
|
}
|
|
|
|
private string GetApiUrl() => string.IsNullOrEmpty(_AppSettings.ApiUrl) ? Url.Content("~/") : _AppSettings.ApiUrl[0] == '~' ? Url.Content(_AppSettings.ApiUrl) : _AppSettings.ApiUrl;
|
|
|
|
[HttpGet]
|
|
[Route("/")]
|
|
public IActionResult Index()
|
|
{
|
|
ViewBag.ApiUrl = GetApiUrl();
|
|
return View("AwaitingDispo");
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("/AwaitingDispo")]
|
|
[Route("/Metrology/AwaitingDispo")]
|
|
public IActionResult AwaitingDispo()
|
|
{
|
|
ViewBag.ApiUrl = GetApiUrl();
|
|
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 = GetApiUrl();
|
|
return View(m);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("/RunHeaders")]
|
|
[Route("/Metrology/RunHeaders")]
|
|
public IActionResult RunHeaders()
|
|
{
|
|
ViewBag.ApiUrl = GetApiUrl();
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("/Crash")]
|
|
public IActionResult Crash() => throw new Exception("Test unhandled exception");
|
|
} |