Example #1
0
        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);
        }
Example #2
0
        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()));
            }
        }
Example #3
0
        public async Task <IActionResult> DeleteGenre([FromBody] DeleteGenreCommand command)
        {
            await _mediator.Send(command, HttpContext.RequestAborted);

            return(Ok());
        }