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