From 85ff9a59035c4d881707b31e9dbbeabf6109f741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Wed, 25 Aug 2021 11:30:50 +0500 Subject: [PATCH] StatController mathod renames --- .../Services/IWellOperationsStatService.cs | 4 +-- .../Services/WellOperationsStatService.cs | 4 +-- .../WellOperationStatController.cs | 33 ++++++++++--------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/AsbCloudApp/Services/IWellOperationsStatService.cs b/AsbCloudApp/Services/IWellOperationsStatService.cs index d0ca7175..85c60f82 100644 --- a/AsbCloudApp/Services/IWellOperationsStatService.cs +++ b/AsbCloudApp/Services/IWellOperationsStatService.cs @@ -7,7 +7,7 @@ namespace AsbCloudApp.Services { public interface IWellOperationsStatService { - Task GetOperationStatByClusterAsync(int idCluster, CancellationToken token = default); - Task GetOperationStatByWellAsync(int idWell, CancellationToken token = default); + Task GetStatClusterAsync(int idCluster, CancellationToken token = default); + Task GetStatWellAsync(int idWell, CancellationToken token = default); } } diff --git a/AsbCloudInfrastructure/Services/WellOperationsStatService.cs b/AsbCloudInfrastructure/Services/WellOperationsStatService.cs index 0ab66869..2d3eada1 100644 --- a/AsbCloudInfrastructure/Services/WellOperationsStatService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationsStatService.cs @@ -77,7 +77,7 @@ namespace AsbCloudInfrastructure.Services cacheCluster = cache.GetCachedTable((DbContext)db); } - public async Task GetOperationStatByClusterAsync(int idCluster, CancellationToken token = default) + public async Task GetStatClusterAsync(int idCluster, CancellationToken token = default) { var operations = await db.WellOperations .Where(o => o.Well.IdCluster == idCluster) @@ -106,7 +106,7 @@ namespace AsbCloudInfrastructure.Services return statClusterDto; } - public async Task GetOperationStatByWellAsync(int idWell, + public async Task GetStatWellAsync(int idWell, CancellationToken token = default) { var operations = await db.WellOperations diff --git a/AsbCloudWebApi/Controllers/WellOperationStatController.cs b/AsbCloudWebApi/Controllers/WellOperationStatController.cs index a1b7d46a..5983689d 100644 --- a/AsbCloudWebApi/Controllers/WellOperationStatController.cs +++ b/AsbCloudWebApi/Controllers/WellOperationStatController.cs @@ -25,35 +25,36 @@ namespace AsbCloudWebApi.Controllers this.wellService = wellService; } - [HttpGet] - [Route("well/{idWell}/stat")] - [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] - public async Task GetOperationStatByWellAsync(int idWell, - CancellationToken token = default) - { - if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) - return Forbid(); - - var result = await sectionsService.GetOperationStatByWellAsync(idWell, token) - .ConfigureAwait(false); - return Ok(result); - } - [HttpGet] [Route("cluster/{idCluster}/stat")] [ProducesResponseType(typeof(StatClusterDto), (int)System.Net.HttpStatusCode.OK)] - public async Task GetOperationStatByClusterAsync(int idCluster, + public async Task GetStatClusterAsync(int idCluster, CancellationToken token = default) { // TODO: Fix next commented lines //if (!await CanUserAccessToWellAsync(idCluster, token).ConfigureAwait(false)) // return Forbid(); - var result = await sectionsService.GetOperationStatByClusterAsync(idCluster, token) + var result = await sectionsService.GetStatClusterAsync(idCluster, token) .ConfigureAwait(false); return Ok(result); } + [HttpGet] + [Route("well/{idWell}/stat")] + [ProducesResponseType(typeof(StatWellDto), (int)System.Net.HttpStatusCode.OK)] + public async Task GetStatWellAsync(int idWell, + CancellationToken token = default) + { + if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) + return Forbid(); + + var result = await sectionsService.GetStatWellAsync(idWell, token) + .ConfigureAwait(false); + return Ok(result); + } + + private async Task CanUserAccessToWellAsync(int idWell, CancellationToken token = default) { int? idCompany = User.GetCompanyId();