| | 1 | | using Microsoft.AspNetCore.Authorization; |
| | 2 | | using Microsoft.AspNetCore.Mvc; |
| | 3 | | using WebApi.Models; |
| | 4 | | using WebApi.Services; |
| | 5 | |
|
| | 6 | | namespace WebApi.Controllers; |
| | 7 | |
|
| | 8 | | [ApiController] |
| | 9 | | [Route("[controller]")] |
| | 10 | | public class GetEnvironmentDataController : ControllerBase |
| | 11 | | { |
| | 12 | | private ISensorDataService _sensorDataService; |
| | 13 | |
|
| 6 | 14 | | public GetEnvironmentDataController(ISensorDataService sensorDataService) |
| 6 | 15 | | { |
| 6 | 16 | | _sensorDataService = sensorDataService; |
| 6 | 17 | | } |
| | 18 | |
|
| | 19 | |
|
| | 20 | | [HttpGet("{hallId}")] |
| | 21 | | [Authorize(Policy = "MustBeAdmin")] |
| | 22 | | public async Task<List<SensorData>> GetSensorData(int hallId) |
| 2 | 23 | | { |
| 2 | 24 | | return await _sensorDataService.GetSensorData(hallId); |
| 2 | 25 | | } |
| | 26 | |
|
| | 27 | | [HttpGet("{hallId}/{limit}")] |
| | 28 | | [Authorize(Policy = "MustBeAdmin")] |
| | 29 | | public async Task<List<SensorData>> GetSensorData(int hallId, int limit) |
| 3 | 30 | | { |
| 3 | 31 | | return await _sensorDataService.GetSensorData(hallId,limit); |
| 3 | 32 | | } |
| | 33 | |
|
| | 34 | | [HttpGet("{hallId}/range")] |
| | 35 | | [Authorize(Policy = "MustBeAdmin")] |
| | 36 | | public async Task<List<SensorData>> GetSensorData(int hallId, DateTime startDate, DateTime endDate) |
| 1 | 37 | | { |
| 1 | 38 | | return await _sensorDataService.GetSensorData(hallId, startDate, endDate); |
| 1 | 39 | | } |
| | 40 | | } |