From 6cb36947cbaeb04aeb6c56548e5f3d8d834253f9 Mon Sep 17 00:00:00 2001 From: Jeas0001 Date: Mon, 31 Mar 2025 11:16:16 +0200 Subject: [PATCH] Made the datetime optional --- backend/Api/Controllers/DeviceController.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/Api/Controllers/DeviceController.cs b/backend/Api/Controllers/DeviceController.cs index 7cee3ad..67727b3 100644 --- a/backend/Api/Controllers/DeviceController.cs +++ b/backend/Api/Controllers/DeviceController.cs @@ -45,8 +45,19 @@ namespace Api.Controllers // Sends the deviceId to deviceLogic [Authorize] [HttpGet("logs/{deviceId}")] - public async Task GetLogs([FromBody] DateTimeRange dateTimeRange, int deviceId) + public async Task 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); }