Added Viewer and
change to App Setting File from Constants
This commit is contained in:
60
Viewer/Controllers/PagesController.cs
Normal file
60
Viewer/Controllers/PagesController.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using OI.Metrology.Shared.ViewModels;
|
||||
using OI.Metrology.Viewer.Models;
|
||||
using System;
|
||||
|
||||
namespace OI.Metrology.Viewer.Controllers;
|
||||
|
||||
public class PagesController : Controller
|
||||
{
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly bool _IsTestDatabase;
|
||||
|
||||
public PagesController(AppSettings appSettings, IMetrologyRepo repo)
|
||||
{
|
||||
_Repo = repo;
|
||||
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public override void OnActionExecuted(ActionExecutedContext context)
|
||||
{
|
||||
base.OnActionExecuted(context);
|
||||
ViewBag.IsTestDatabase = _IsTestDatabase;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/")]
|
||||
public IActionResult Index() =>
|
||||
View("AwaitingDispo");
|
||||
|
||||
[HttpGet]
|
||||
[Route("/AwaitingDispo")]
|
||||
public IActionResult AwaitingDispo() => View();
|
||||
|
||||
[HttpGet]
|
||||
[Route("/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 = _Repo.GetHeaderAttachmentID(tooltypeid, headerid);
|
||||
}
|
||||
return View(m);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("/RunHeaders")]
|
||||
public IActionResult RunHeaders() => View();
|
||||
|
||||
[HttpGet]
|
||||
[Route("/Crash")]
|
||||
public IActionResult Crash() => throw new Exception("Test unhandled exception");
|
||||
}
|
Reference in New Issue
Block a user