TrafficLightsCSharp/TrafficLights/Pages/GetStatus.cshtml.cs

20 lines
636 B
C#
Raw Normal View History

2023-11-04 11:02:30 +00:00
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace TrafficLights.Pages
{
public class GetStatusModel : PageModel
{
private readonly TrafficLightSimulatorService _trafficLightSimulatorService;
public GetStatusModel(TrafficLightSimulatorService trafficLightSimulatorService)
{
_trafficLightSimulatorService = trafficLightSimulatorService;
}
public IActionResult OnGet()
{
var currentStatus = _trafficLightSimulatorService.GetStatus();
return new JsonResult(currentStatus);
}
}
}