public async Task DeleteGenreTestNormal() { var genreToDelete = _genreFaker.Generate(); _dbContext.GetGenre(genreToDelete.Id).Returns(genreToDelete); var deleteGenreCommandHandler = new DeleteGenreCommandHandler(_dbContext); var deleteGenreCommand = new DeleteGenreCommand { Id = genreToDelete.Id }; var deleted = await deleteGenreCommandHandler.Handle(deleteGenreCommand, CancellationToken.None); deleted.Should().Be(true); }
public async Task <IActionResult> Delete([FromRoute] Guid genreId) { var addNewGenreCommand = new DeleteGenreCommand { Id = genreId }; try { var deleted = await _mediator.Send(addNewGenreCommand); if (deleted) { return(NoContent()); } return(NotFound()); } catch (Exception e) { return(BadRequest(e.ToString())); } }
public async Task <IActionResult> DeleteGenre([FromBody] DeleteGenreCommand command) { await _mediator.Send(command, HttpContext.RequestAborted); return(Ok()); }