forked from ddrilling/AsbCloudServer
fix MeasureController.GetHisoryAsync
This commit is contained in:
parent
d40bced3a0
commit
ea26010719
@ -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, int? idCategory, CancellationToken token);
|
||||
Task<int> InsertAsync(int idWell, MeasureDto data, CancellationToken token);
|
||||
Task<int> UpdateAsync(int idWell, MeasureDto data, CancellationToken token);
|
||||
Task<int> MarkAsDeleteAsync(int idWell, int idData, CancellationToken token);
|
||||
|
@ -47,10 +47,13 @@ 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, int? idCategory = null, CancellationToken token = default)
|
||||
{
|
||||
var query = db.Measures.Include(m => m.Category)
|
||||
.Where(m => m.IdWell == idWell && !m.IsDeleted && m.IdCategory == idCategory);
|
||||
.Where(m => m.IdWell == idWell && !m.IsDeleted);
|
||||
|
||||
if(idCategory is not null)
|
||||
query = query.Where(m => m.IdCategory == idCategory);
|
||||
|
||||
var entities = await query
|
||||
.OrderBy(m => m.Timestamp)
|
||||
|
@ -43,9 +43,16 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// История замеров по скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="idCategory">Категория скважины. Не обязательный параметр. По умолчанию null</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("history")]
|
||||
public async Task<IActionResult> GetHisoryAsync([FromRoute] int idWell, [FromRoute] int idCategory, CancellationToken token = default)
|
||||
[Route("history/{idCategory?}")]
|
||||
public async Task<IActionResult> GetHisoryAsync([FromRoute] int idWell, int? idCategory = null, CancellationToken token = default)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
Loading…
Reference in New Issue
Block a user