public async Task DeleteAppealFile_removes_AppealFile_from_Application_Appeal() { var applicationId = AutoFixture.Create <Guid>(); var fileName = AutoFixture.Create <string>(); var request = new DeleteAppealFileRequest { UserId = AutoFixture.Create <string>(), UserName = AutoFixture.Create <string>() }; _mediator.Setup(x => x.Send(It.IsAny <DeleteAppealFileCommand>(), It.IsAny <CancellationToken>())).ReturnsAsync(Unit.Value); _fileStorageService.Setup(x => x.DeleteApplicationFile(applicationId, fileName, It.IsAny <ContainerType>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); var result = await _controller.DeleteAppealFile(applicationId, fileName, request); result.Should().BeOfType <OkResult>(); _mediator.Verify( x => x.Send(It.Is <DeleteAppealFileCommand>(c => c.ApplicationId == applicationId && c.FileName == fileName && c.UserId == request.UserId && c.UserName == request.UserName), It.IsAny <CancellationToken>()), Times.Once); _fileStorageService.Verify(x => x.DeleteApplicationFile(applicationId, fileName, It.IsAny <ContainerType>(), It.IsAny <CancellationToken>()), Times.Once); }
public async Task <bool> DeleteFile(Guid applicationId, string fileName, string signinId, string userName) { var request = new DeleteAppealFileRequest { UserId = signinId, UserName = userName }; var result = await Post($"/Appeals/{applicationId}/files/delete/{fileName}", request); return(result == HttpStatusCode.OK); }
public async Task <IActionResult> DeleteAppealFile(Guid applicationId, string fileName, [FromBody] DeleteAppealFileRequest request) { var command = new DeleteAppealFileCommand { ApplicationId = applicationId, FileName = fileName, UserId = request.UserId, UserName = request.UserName }; await _mediator.Send(command); var deletedSuccessfully = await _fileStorageService.DeleteApplicationFile(applicationId, fileName, ContainerType.Appeals, new CancellationToken()); if (!deletedSuccessfully) { _logger.LogError($"Unable to delete appeal file for application: {applicationId} || filename {fileName}"); } return(new OkResult()); }