39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
|
using Microsoft.AspNetCore.Mvc;
|
||
|
using Persistence.Models;
|
||
|
using Persistence.Repositories;
|
||
|
|
||
|
namespace Persistence.API.Controllers;
|
||
|
[ApiController]
|
||
|
[Route("api/[controller]")]
|
||
|
public class TimeSeriesController<TDto> : ControllerBase, ITimeSeriesDataApi<TDto>
|
||
|
where TDto : class, ITimeSeriesAbstractDto, new()
|
||
|
{
|
||
|
private ITimeSeriesDataRepository<TDto> timeSeriesDataRepository;
|
||
|
|
||
|
public TimeSeriesController(ITimeSeriesDataRepository<TDto> timeSeriesDataRepository)
|
||
|
{
|
||
|
this.timeSeriesDataRepository = timeSeriesDataRepository;
|
||
|
}
|
||
|
|
||
|
[HttpGet]
|
||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||
|
public async Task<IActionResult> GetAsync(DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
|
||
|
{
|
||
|
var result = await this.timeSeriesDataRepository.GetAsync(dateBegin, dateEnd, token);
|
||
|
return Ok(result);
|
||
|
}
|
||
|
|
||
|
[HttpGet("datesRange")]
|
||
|
public Task<IActionResult> GetDatesRangeAsync(CancellationToken token)
|
||
|
{
|
||
|
throw new NotImplementedException();
|
||
|
}
|
||
|
|
||
|
[HttpPost]
|
||
|
public async Task<IActionResult> InsertRangeAsync(IEnumerable<TDto> dtos, CancellationToken token)
|
||
|
{
|
||
|
var result = await this.timeSeriesDataRepository.InsertRange(dtos, token);
|
||
|
return Ok(result);
|
||
|
}
|
||
|
}
|