diff --git a/AsbCloudApp/Services/IMeasureService.cs b/AsbCloudApp/Services/IMeasureService.cs index afaef573..ea8b930b 100644 --- a/AsbCloudApp/Services/IMeasureService.cs +++ b/AsbCloudApp/Services/IMeasureService.cs @@ -9,7 +9,7 @@ namespace AsbCloudApp.Services { Task> GetCategoriesAsync(CancellationToken token); Task GetLastAsync(int idWell, int idCategory, CancellationToken token); - Task> GetHisoryAsync(int idWell, int idCategory, CancellationToken token); + Task> GetHisoryAsync(int idWell, int? idCategory, CancellationToken token); Task InsertAsync(int idWell, MeasureDto data, CancellationToken token); Task UpdateAsync(int idWell, MeasureDto data, CancellationToken token); Task MarkAsDeleteAsync(int idWell, int idData, CancellationToken token); diff --git a/AsbCloudInfrastructure/Services/MeasureService.cs b/AsbCloudInfrastructure/Services/MeasureService.cs index e0fe0da4..d1beed71 100644 --- a/AsbCloudInfrastructure/Services/MeasureService.cs +++ b/AsbCloudInfrastructure/Services/MeasureService.cs @@ -47,10 +47,13 @@ namespace AsbCloudInfrastructure.Services return dtos; } - public async Task> GetHisoryAsync(int idWell, int idCategory, CancellationToken token) + public async Task> 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) diff --git a/AsbCloudWebApi/Controllers/MeasureController.cs b/AsbCloudWebApi/Controllers/MeasureController.cs index aba583c3..499ea590 100644 --- a/AsbCloudWebApi/Controllers/MeasureController.cs +++ b/AsbCloudWebApi/Controllers/MeasureController.cs @@ -43,9 +43,16 @@ namespace AsbCloudWebApi.Controllers return Ok(result); } + /// + /// История замеров по скважине + /// + /// + /// Категория скважины. Не обязательный параметр. По умолчанию null + /// + /// [HttpGet] - [Route("history")] - public async Task GetHisoryAsync([FromRoute] int idWell, [FromRoute] int idCategory, CancellationToken token = default) + [Route("history/{idCategory?}")] + public async Task GetHisoryAsync([FromRoute] int idWell, int? idCategory = null, CancellationToken token = default) { if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) return Forbid();