Added backend API project to segregate responsibilites - Data is now handled in API project and business is all handled in UI project.

This commit is contained in:
Daniel Wathen
2023-01-04 14:19:59 -07:00
parent 80696e5fe6
commit 1adb303d99
33 changed files with 762 additions and 95 deletions

View File

@ -1,12 +1,14 @@
using Microsoft.AspNetCore.Mvc;
using ReportingServices.Shared.Repositories;
using ReportingServices.Shared.Models.PlanningReport;
using ReportingServices.Shared.HelperClasses;
namespace ReportingServices.UI.Controllers
{
public class PlanningReportController : Controller
{
private readonly IScrapeDatabaseRepository _scrapeDatabaseRepository;
private readonly string _baseUrl = "https://localhost:7196/api/ScrapeDB/";
public PlanningReportController(IScrapeDatabaseRepository scrapeDatabaseRepository)
{
@ -18,10 +20,13 @@ namespace ReportingServices.UI.Controllers
return View();
}
public IActionResult WeeklyPartChangesReport(DateTime startDate, DateTime endDate)
public async Task<IActionResult> WeeklyPartChangesReport(DateTime startDate, DateTime endDate)
{
int numberOfPartChanges = _scrapeDatabaseRepository.GetNumberOfPartChanges(startDate.ToString(), endDate.ToString());
List<ReactorPSNWORuns> reactorPSNWORuns = _scrapeDatabaseRepository.GetReactorPSNWORuns(startDate.ToString(), endDate.ToString());
string partChangeUrl = _baseUrl + "PartChanges?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString();
string psnwoRunsUrl = _baseUrl + "PSNWO?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString();
int numberOfPartChanges = await ApiCaller.GetApi<int>(partChangeUrl);
List<ReactorPSNWORuns> reactorPSNWORuns = await ApiCaller.GetApi<List<ReactorPSNWORuns>>(psnwoRunsUrl);
WeeklyPartChanges weeklyPartChanges = new()
{

View File

@ -34,7 +34,7 @@ namespace ReportingServices.UI.Controllers
try
{
DailyReportHelper.SetRepositories(_fabTimeReportingRepository, _scrapeDatabaseRepository);
DailyReport dailyReport = DailyReportHelper.SetUpDailyReport();
DailyReport dailyReport = DailyReportHelper.SetUpDailyReport().Result;
Dictionary<string, List<string>> toolStateOwners = JsonFileHandler.LoadJSONFile<Dictionary<string, List<string>>>(_toolStateOwnerFilePath);
dailyReport.ToolStatesByOwner = toolStateOwners;