using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Persistence.Models; using Persistence.Repositories; namespace Persistence.API.Controllers; [ApiController] [Authorize] [Route("api/[controller]")] public class TimeSeriesController : ControllerBase, ITimeSeriesDataApi where TDto : class, ITimeSeriesAbstractDto, new() { private ITimeSeriesDataRepository timeSeriesDataRepository; public TimeSeriesController(ITimeSeriesDataRepository timeSeriesDataRepository) { this.timeSeriesDataRepository = timeSeriesDataRepository; } [HttpGet] [ProducesResponseType(StatusCodes.Status200OK)] public async Task Get(DateTimeOffset dateBegin, CancellationToken token) { var result = await this.timeSeriesDataRepository.GetGtDate(dateBegin, token); return Ok(result); } [HttpGet("datesRange")] public async Task GetDatesRange(CancellationToken token) { var result = await this.timeSeriesDataRepository.GetDatesRange(token); return Ok(result); } public Task GetResampledData(DateTimeOffset dateBegin, DateTimeOffset dateEnd, int approxPointsCount = 1024) { throw new NotImplementedException(); } [HttpPost] public async Task InsertRange(IEnumerable dtos, CancellationToken token) { var result = await this.timeSeriesDataRepository.InsertRange(dtos, token); return Ok(result); } }