43 lines
1.6 KiB
C#

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)
{
_scrapeDatabaseRepository = scrapeDatabaseRepository;
}
public IActionResult Index()
{
return View();
}
public async Task<IActionResult> WeeklyPartChangesReport(DateTime startDate, DateTime endDate)
{
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()
{
TotalPartChanges = numberOfPartChanges,
StartDate = startDate.ToShortDateString(),
EndDate = endDate.ToShortDateString(),
ReactorPSNWORuns = reactorPSNWORuns
};
return View(weeklyPartChanges);
}
}
}