StatController mathod renames

This commit is contained in:
Фролов 2021-08-25 11:30:50 +05:00
parent e55f505ea7
commit 85ff9a5903
3 changed files with 21 additions and 20 deletions

View File

@ -7,7 +7,7 @@ namespace AsbCloudApp.Services
{ {
public interface IWellOperationsStatService public interface IWellOperationsStatService
{ {
Task<StatClusterDto> GetOperationStatByClusterAsync(int idCluster, CancellationToken token = default); Task<StatClusterDto> GetStatClusterAsync(int idCluster, CancellationToken token = default);
Task<StatWellDto> GetOperationStatByWellAsync(int idWell, CancellationToken token = default); Task<StatWellDto> GetStatWellAsync(int idWell, CancellationToken token = default);
} }
} }

View File

@ -77,7 +77,7 @@ namespace AsbCloudInfrastructure.Services
cacheCluster = cache.GetCachedTable<Cluster>((DbContext)db); cacheCluster = cache.GetCachedTable<Cluster>((DbContext)db);
} }
public async Task<StatClusterDto> GetOperationStatByClusterAsync(int idCluster, CancellationToken token = default) public async Task<StatClusterDto> GetStatClusterAsync(int idCluster, CancellationToken token = default)
{ {
var operations = await db.WellOperations var operations = await db.WellOperations
.Where(o => o.Well.IdCluster == idCluster) .Where(o => o.Well.IdCluster == idCluster)
@ -106,7 +106,7 @@ namespace AsbCloudInfrastructure.Services
return statClusterDto; return statClusterDto;
} }
public async Task<StatWellDto> GetOperationStatByWellAsync(int idWell, public async Task<StatWellDto> GetStatWellAsync(int idWell,
CancellationToken token = default) CancellationToken token = default)
{ {
var operations = await db.WellOperations var operations = await db.WellOperations

View File

@ -25,35 +25,36 @@ namespace AsbCloudWebApi.Controllers
this.wellService = wellService; this.wellService = wellService;
} }
[HttpGet]
[Route("well/{idWell}/stat")]
[ProducesResponseType(typeof(IEnumerable<StatOperationsDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> 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] [HttpGet]
[Route("cluster/{idCluster}/stat")] [Route("cluster/{idCluster}/stat")]
[ProducesResponseType(typeof(StatClusterDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(StatClusterDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetOperationStatByClusterAsync(int idCluster, public async Task<IActionResult> GetStatClusterAsync(int idCluster,
CancellationToken token = default) CancellationToken token = default)
{ {
// TODO: Fix next commented lines // TODO: Fix next commented lines
//if (!await CanUserAccessToWellAsync(idCluster, token).ConfigureAwait(false)) //if (!await CanUserAccessToWellAsync(idCluster, token).ConfigureAwait(false))
// return Forbid(); // return Forbid();
var result = await sectionsService.GetOperationStatByClusterAsync(idCluster, token) var result = await sectionsService.GetStatClusterAsync(idCluster, token)
.ConfigureAwait(false); .ConfigureAwait(false);
return Ok(result); return Ok(result);
} }
[HttpGet]
[Route("well/{idWell}/stat")]
[ProducesResponseType(typeof(StatWellDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> 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<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default) private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();