Ejemplo n.º 1
0
        public async Task<ActionResult<List<Room>>> RoomAlarms(Guid id, [FromQuery] bool openOnly = false,
            CancellationToken ct = default)
        {
            try
            {
                var room = await _roomService.GetRoomByIdAsync(id, ct);

                if (room.IsNull())
                    return NotFound();

                var roomAlarms = openOnly ? 
                    await _alarmService.GetAlarmsByStatusForRoomAsync(room, Core.Shared.Enums.AlarmStatus.Open, ct) :
                    await _alarmService.GetAlarmsForRoomAsync(room, ct);

                return Ok(roomAlarms);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Exception running {Controller} {Action}",
                   "Room", "Index");
                return new StatusCodeResult(StatusCodes.Status500InternalServerError);
            }
        }