oi-metrology/Archive/ApiControllers/ReactorsController.cs
2023-01-06 08:40:35 -07:00

99 lines
1.9 KiB
C#

using Microsoft.AspNetCore.Mvc;
using System.Linq;
namespace OI.Metrology.Archive.ApiContollers;
using OI.Metrology.Archive.Models;
using OI.Metrology.Shared.Repositories;
using System.Text.Json;
public class ReactorsController : Controller
{
private readonly IMetrologyRepo _Repo;
private readonly AppSettings _AppSettings;
public ReactorsController(AppSettings appSettings, IMetrologyRepo repo)
{
_Repo = repo;
_AppSettings = appSettings;
}
private static int[] EvenReactors()
{
int[] results = new int[] {
20,
22,
24,
26,
28,
30,
32,
34,
36,
38,
40,
42,
44,
46,
48,
50,
52,
54,
56,
58,
60,
62,
64,
66,
68,
70,
72,
74
};
return results;
}
private static int[] OddReactors()
{
int[] results = new int[] {
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
73,
75,
77,
79
};
return results;
}
[HttpGet("/api/reactors/{even}")]
public IActionResult Index(bool even)
{
int[] n = even ? EvenReactors() : OddReactors();
var r = n.Select(l => new { Name = $"R{l}", Id = l });
return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
}
}