Fixed Measure controller to return all measure history at once

This commit is contained in:
KharchenkoVV 2021-10-05 18:02:02 +05:00
parent 5b41d017a1
commit 1f4a55c5df
3 changed files with 5 additions and 5 deletions

View File

@ -9,7 +9,7 @@ namespace AsbCloudApp.Services
{
Task<Dictionary<int, string>> GetCategoriesAsync(CancellationToken token);
Task<MeasureDto> GetLastAsync(int idWell, int idCategory, CancellationToken token);
Task<IEnumerable<MeasureDto>> GetHisoryAsync(int idWell, int idCategory, CancellationToken token);
Task<IEnumerable<MeasureDto>> GetHisoryAsync(int idWell, CancellationToken token);
Task<IEnumerable<MeasureDto>> GetAllLastAsync(int idWell, CancellationToken token);
Task<int> InsertAsync(int idWell, MeasureDto data, CancellationToken token);
Task<int> UpdateAsync(int idWell, MeasureDto data, CancellationToken token);

View File

@ -83,10 +83,10 @@ namespace AsbCloudInfrastructure.Services
return dtos;
}
public async Task<IEnumerable<MeasureDto>> GetHisoryAsync(int idWell, int idCategory, CancellationToken token)
public async Task<IEnumerable<MeasureDto>> GetHisoryAsync(int idWell, CancellationToken token)
{
var query = db.Measures.Include(m => m.Category)
.Where(m => m.IdWell == idWell && m.IdCategory == idCategory && !m.IsDeleted);
.Where(m => m.IdWell == idWell && !m.IsDeleted);
var entities = await query
.AsNoTracking()

View File

@ -55,13 +55,13 @@ namespace AsbCloudWebApi.Controllers
}
[HttpGet]
[Route("history/{idCategory}")]
[Route("history")]
public async Task<IActionResult> GetHisoryAsync([FromRoute] int idWell, [FromRoute] int idCategory, CancellationToken token = default)
{
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid();
var result = await measureService.GetHisoryAsync(idWell, idCategory, token).ConfigureAwait(false);
var result = await measureService.GetHisoryAsync(idWell, token).ConfigureAwait(false);
return Ok(result);
}