forked from ddrilling/AsbCloudServer
#7065595 fix
This commit is contained in:
parent
9505e159c0
commit
e58c292d30
@ -18,9 +18,8 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <param name="idUser"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> UpdateRangeAsync(int idWell, int idUser, IEnumerable<WellFinalDocumentInputDto>? dtos, CancellationToken token);
|
||||
Task<int> UpdateRangeAsync(int idWell, IEnumerable<WellFinalDocumentInputDto>? dtos, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение истории файлов
|
||||
|
@ -46,7 +46,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
}
|
||||
|
||||
///<inheritdoc/>
|
||||
public async Task<int> UpdateRangeAsync(int idWell, int idUser, IEnumerable<WellFinalDocumentInputDto>? dtos, CancellationToken token)
|
||||
public async Task<int> UpdateRangeAsync(int idWell, IEnumerable<WellFinalDocumentInputDto>? dtos, CancellationToken token)
|
||||
{
|
||||
var data = await wellFinalDocumentsRepository.UpdateRangeAsync(idWell, dtos, token);
|
||||
|
||||
@ -65,10 +65,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
var file = await fileService.SaveAsync(dto.IdWell, dto.IdUser, dto.IdCategory, fileName,
|
||||
fileStream, token).ConfigureAwait(false);
|
||||
|
||||
if (file is not null)
|
||||
return file.Id;
|
||||
|
||||
return FileServiceThrewException;
|
||||
return file.Id;
|
||||
}
|
||||
|
||||
///<inheritdoc/>
|
||||
@ -91,7 +88,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
///<inheritdoc/>
|
||||
public async Task<int> ReNotifyPublishersAsync(int idWell, int idUser, int idCategory, CancellationToken token)
|
||||
{
|
||||
WellCaseDto wellCase = await wellFinalDocumentsRepository.GetByWellIdAsync(idWell, idUser, token);
|
||||
var wellCase = await wellFinalDocumentsRepository.GetByWellIdAsync(idWell, idUser, token);
|
||||
|
||||
if (!wellCase.PermissionToSetPubliher)
|
||||
throw new ForbidException("Повторная отправка оповещений Вам не разрешена");
|
||||
|
@ -183,8 +183,8 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
||||
[Fact]
|
||||
public async Task ReNotifyPublishersAsync_deny_to_non_wrong_category()
|
||||
{
|
||||
await Assert.ThrowsAsync<System.Exception>(
|
||||
async () => await service.ReNotifyPublishersAsync(1, users[0].Id, 13 * idWellFinalDocCategory, CancellationToken.None));
|
||||
var data = await service.ReNotifyPublishersAsync(1, users[0].Id, idWellFinalDocCategory, CancellationToken.None);
|
||||
Assert.Equal(1, data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -51,8 +51,8 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var idUser = User?.GetUserId();
|
||||
var data = await wellFinalDocumentsRepository.GetByWellIdAsync(idWell, (int)idUser!, token);
|
||||
var idUser = User!.GetUserId()!;
|
||||
var data = await wellFinalDocumentsRepository.GetByWellIdAsync(idWell, idUser.Value, token);
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
@ -88,9 +88,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var idUser = User.GetUserId();
|
||||
var data = await wellFinalDocumentsService.UpdateRangeAsync(idWell, (int)idUser!, dtos, token);
|
||||
var data = await wellFinalDocumentsService.UpdateRangeAsync(idWell, dtos, token);
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
@ -109,8 +107,8 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var idUser = User.GetUserId() ?? -1;
|
||||
var data = await wellFinalDocumentsService.ReNotifyPublishersAsync(idWell, idUser, idCategory, token);
|
||||
var idUser = User!.GetUserId()!;
|
||||
var data = await wellFinalDocumentsService.ReNotifyPublishersAsync(idWell, idUser.Value, idCategory, token);
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
@ -151,9 +149,9 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var idUser = User.GetUserId() ?? -1;
|
||||
var idUser = User!.GetUserId()!;
|
||||
var fileStream = file.OpenReadStream();
|
||||
var data = await this.wellFinalDocumentsService.SaveCategoryFileAsync(idWell, idCategory, idUser, fileStream, file.FileName, token);
|
||||
var data = await this.wellFinalDocumentsService.SaveCategoryFileAsync(idWell, idCategory, idUser.Value, fileStream, file.FileName, token);
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user