49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Persistence.Models;
|
|
using Persistence.Repositories;
|
|
|
|
namespace Persistence.API.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class SetpointController : ControllerBase, ISetpointApi
|
|
{
|
|
private readonly ISetpointRepository setpointRepository;
|
|
|
|
public SetpointController(ISetpointRepository setpointRepository)
|
|
{
|
|
this.setpointRepository = setpointRepository;
|
|
}
|
|
|
|
[HttpPost("current")]
|
|
public Task<ActionResult<IEnumerable<SetpointValueDto>>> GetCurrentAsync(IEnumerable<Guid> setpointKeys, CancellationToken token)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
[HttpPost("history")]
|
|
public async Task<ActionResult<IEnumerable<SetpointValueDto>>> GetHistoryAsync(IEnumerable<Guid> setpointKeys, DateTimeOffset historyMoment, CancellationToken token)
|
|
{
|
|
var result = await setpointRepository.GetHistoryAsync(setpointKeys, historyMoment, token);
|
|
|
|
return Ok(result);
|
|
}
|
|
|
|
[HttpPost("log")]
|
|
public async Task<ActionResult<Dictionary<Guid, IEnumerable<SetpointLogDto>>>> GetLogAsync([FromBody] IEnumerable<Guid> setpointKeys, CancellationToken token)
|
|
{
|
|
var result = await setpointRepository.GetLogAsync(setpointKeys, token);
|
|
|
|
return Ok(result);
|
|
}
|
|
|
|
[HttpPost("save")]
|
|
public async Task<ActionResult<int>> SaveAsync(Guid setpointKey, object newValue, CancellationToken token)
|
|
{
|
|
var result = await setpointRepository.SaveAsync(setpointKey, newValue, token);
|
|
|
|
return Ok(result);
|
|
}
|
|
}
|
|
}
|