diff --git a/AsbCloudApp/Services/IWellFinalDocumentsService.cs b/AsbCloudApp/Services/IWellFinalDocumentsService.cs index bdcb51f8..63536c7c 100644 --- a/AsbCloudApp/Services/IWellFinalDocumentsService.cs +++ b/AsbCloudApp/Services/IWellFinalDocumentsService.cs @@ -18,9 +18,8 @@ namespace AsbCloudApp.Services /// /// /// - /// /// - Task UpdateRangeAsync(int idWell, int idUser, IEnumerable? dtos, CancellationToken token); + Task UpdateRangeAsync(int idWell, IEnumerable? dtos, CancellationToken token); /// /// Получение истории файлов diff --git a/AsbCloudInfrastructure/Services/WellFinalDocumentsService.cs b/AsbCloudInfrastructure/Services/WellFinalDocumentsService.cs index 1da4b617..31262718 100644 --- a/AsbCloudInfrastructure/Services/WellFinalDocumentsService.cs +++ b/AsbCloudInfrastructure/Services/WellFinalDocumentsService.cs @@ -46,7 +46,7 @@ namespace AsbCloudInfrastructure.Services } /// - public async Task UpdateRangeAsync(int idWell, int idUser, IEnumerable? dtos, CancellationToken token) + public async Task UpdateRangeAsync(int idWell, IEnumerable? 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; } /// @@ -91,7 +88,7 @@ namespace AsbCloudInfrastructure.Services /// public async Task 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("Повторная отправка оповещений Вам не разрешена"); diff --git a/AsbCloudWebApi.Tests/ServicesTests/WellFinalDocumentsServiceTest.cs b/AsbCloudWebApi.Tests/ServicesTests/WellFinalDocumentsServiceTest.cs index 290922cd..ef1cac15 100644 --- a/AsbCloudWebApi.Tests/ServicesTests/WellFinalDocumentsServiceTest.cs +++ b/AsbCloudWebApi.Tests/ServicesTests/WellFinalDocumentsServiceTest.cs @@ -183,8 +183,8 @@ namespace AsbCloudWebApi.Tests.ServicesTests [Fact] public async Task ReNotifyPublishersAsync_deny_to_non_wrong_category() { - await Assert.ThrowsAsync( - 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] diff --git a/AsbCloudWebApi/Controllers/WellFinalDocumentsController.cs b/AsbCloudWebApi/Controllers/WellFinalDocumentsController.cs index 15c714da..ee89eda6 100644 --- a/AsbCloudWebApi/Controllers/WellFinalDocumentsController.cs +++ b/AsbCloudWebApi/Controllers/WellFinalDocumentsController.cs @@ -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); }