Compare commits

...

2 Commits

Author SHA1 Message Date
Jeas0001
1ca64702d7 Merge branch 'master' of git.reim.ar:ReiMerc/temperature-alarm 2025-03-31 11:16:29 +02:00
Jeas0001
6cb36947cb Made the datetime optional 2025-03-31 11:16:16 +02:00

View File

@ -45,8 +45,19 @@ namespace Api.Controllers
// Sends the deviceId to deviceLogic
[Authorize]
[HttpGet("logs/{deviceId}")]
public async Task<IActionResult> GetLogs([FromBody] DateTimeRange dateTimeRange, int deviceId)
public async Task<IActionResult> GetLogs(int deviceId, DateTime? dateTimeStart = null, DateTime? dateTimeEnd = null)
{
DateTimeRange dateTimeRange = new DateTimeRange();
if (dateTimeStart != null && dateTimeEnd != null)
{
dateTimeRange.DateTimeStart = (DateTime)dateTimeStart;
dateTimeRange.DateTimeEnd= (DateTime)dateTimeEnd;
}
else
{
dateTimeRange.DateTimeStart = DateTime.Now;
dateTimeRange.DateTimeEnd = dateTimeRange.DateTimeStart;
}
return await _deviceLogic.GetLogs(dateTimeRange, deviceId);
}