WellOperation* remove default cancellation tokens

This commit is contained in:
ngfrolov 2022-12-22 11:26:19 +05:00
parent 7b0e6ce23d
commit 9eead7a757
3 changed files with 11 additions and 11 deletions

View File

@ -28,7 +28,7 @@ namespace AsbCloudApp.Services
/// <returns></returns> /// <returns></returns>
Task<PaginationContainer<WellOperationDto>> GetOperationsAsync( Task<PaginationContainer<WellOperationDto>> GetOperationsAsync(
WellOperationRequest request, WellOperationRequest request,
CancellationToken token = default); CancellationToken token);
/// <summary> /// <summary>
/// Получить статистику операции по скважине с группировкой по категориям /// Получить статистику операции по скважине с группировкой по категориям
@ -38,7 +38,7 @@ namespace AsbCloudApp.Services
/// <returns></returns> /// <returns></returns>
Task<IEnumerable<WellGroupOpertionDto>> GetGroupOperationsStatAsync( Task<IEnumerable<WellGroupOpertionDto>> GetGroupOperationsStatAsync(
WellOperationRequest request, WellOperationRequest request,
CancellationToken token = default); CancellationToken token);
/// <summary> /// <summary>
/// Получить операцию по id /// Получить операцию по id
@ -46,7 +46,7 @@ namespace AsbCloudApp.Services
/// <param name="id"></param> /// <param name="id"></param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
Task<WellOperationDto> GetOrDefaultAsync(int id, CancellationToken token); Task<WellOperationDto?> GetOrDefaultAsync(int id, CancellationToken token);
/// <summary> /// <summary>
/// Добавить несколько операций за один раз /// Добавить несколько операций за один раз

View File

@ -78,7 +78,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
public async Task<PaginationContainer<WellOperationDto>> GetOperationsAsync( public async Task<PaginationContainer<WellOperationDto>> GetOperationsAsync(
WellOperationRequest request, WellOperationRequest request,
CancellationToken token = default) CancellationToken token)
{ {
var timezone = wellService.GetTimezone(request.IdWell); var timezone = wellService.GetTimezone(request.IdWell);
@ -124,7 +124,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
public async Task<IEnumerable<WellGroupOpertionDto>> GetGroupOperationsStatAsync( public async Task<IEnumerable<WellGroupOpertionDto>> GetGroupOperationsStatAsync(
WellOperationRequest request, WellOperationRequest request,
CancellationToken token = default) CancellationToken token)
{ {
var query = BuildQuery(request); var query = BuildQuery(request);
var entities = await query var entities = await query
@ -176,7 +176,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
} }
public async Task<WellOperationDto?> GetOrDefaultAsync(int id, public async Task<WellOperationDto?> GetOrDefaultAsync(int id,
CancellationToken token = default) CancellationToken token)
{ {
var entity = await db.WellOperations var entity = await db.WellOperations
.Include(s => s.WellSectionType) .Include(s => s.WellSectionType)
@ -198,7 +198,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
public async Task<int> InsertRangeAsync( public async Task<int> InsertRangeAsync(
IEnumerable<WellOperationDto> wellOperationDtos, IEnumerable<WellOperationDto> wellOperationDtos,
CancellationToken token = default) CancellationToken token)
{ {
var firstOperation = wellOperationDtos var firstOperation = wellOperationDtos
.FirstOrDefault(); .FirstOrDefault();
@ -222,7 +222,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
} }
public async Task<int> UpdateAsync( public async Task<int> UpdateAsync(
WellOperationDto dto, CancellationToken token = default) WellOperationDto dto, CancellationToken token)
{ {
var timezone = wellService.GetTimezone(dto.IdWell); var timezone = wellService.GetTimezone(dto.IdWell);
var entity = dto.Adapt<WellOperation>(); var entity = dto.Adapt<WellOperation>();
@ -233,7 +233,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
} }
public async Task<int> DeleteAsync(IEnumerable<int> ids, public async Task<int> DeleteAsync(IEnumerable<int> ids,
CancellationToken token = default) CancellationToken token)
{ {
var query = db.WellOperations.Where(e => ids.Contains(e.Id)); var query = db.WellOperations.Where(e => ids.Contains(e.Id));
db.WellOperations.RemoveRange(query); db.WellOperations.RemoveRange(query);

View File

@ -123,7 +123,7 @@ namespace AsbCloudWebApi.Controllers
[Route("{idOperation}")] [Route("{idOperation}")]
[Permission] [Permission]
[ProducesResponseType(typeof(WellOperationDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(WellOperationDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAsync(int idWell, int idOperation, public async Task<IActionResult> GetOrDefaultAsync(int idWell, int idOperation,
CancellationToken token) CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
@ -320,7 +320,7 @@ namespace AsbCloudWebApi.Controllers
return File(stream, "application/octet-stream", fileName); return File(stream, "application/octet-stream", fileName);
} }
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default) private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,