public async void Delete(int id)
 {
     //to delete it properly i should provide ID, for now you can't see it anywhere(just in DB)
     var command = new DeleteCharacterCommand()
     {
         characterID = id
     };
     var result = await _mediator.Send(command);
 }
Esempio n. 2
0
        public async Task <ApiResponse> Delete(Guid id)
        {
            var command = new DeleteCharacterCommand
            {
                Id = id
            };
            await _operationMediator.HandleAsync(command);

            return(ApiResponse.Ok());
        }
Esempio n. 3
0
        public async Task <IResponse> Handle(DeleteCharacterCommand command)
        {
            command.Validate();

            if (command.Invalid)
            {
                return(new GenericCommandResponse(false, "Comando Inválido", command.Notifications));
            }

            await _characterRepository.Delete(command.Id);

            return(new GenericCommandResponse(true, "OK", command));
        }
Esempio n. 4
0
        public async Task Delete_character_command_handler_should_pass()
        {
            // Arrange
            var character = new CharacterBuilder().Generate().SaveChanges(_testFixture.Context).Build().First();
            var command   = new DeleteCharacterCommand {
                Id = character.Id
            };
            var commandHandler = new DeleteCharacterCommandHandler(_testFixture.Context);

            // Act
            var response = await commandHandler.Handle(command, CancellationToken.None);

            // Assert
            response.ShouldBe(Unit.Value);
            character.IsActive.ShouldBe(false);
        }
Esempio n. 5
0
        public async Task Delete_character_command_handler_should_throw_not_found_exception()
        {
            // Arrange
            var character = new CharacterBuilder().Generate().SaveChanges(_testFixture.Context).Build().First();
            var command   = new DeleteCharacterCommand {
                Id = character.Id + 1
            };
            var commandHandler = new DeleteCharacterCommandHandler(_testFixture.Context);

            // Act
            async Task Act() => await commandHandler.Handle(command, CancellationToken.None);

            var ex = await Record.ExceptionAsync(Act);

            // Assert
            ex.ShouldBeOfType <NotFoundException>();
        }
Esempio n. 6
0
 public async Task <GenericCommandResponse> Delete([FromBody] DeleteCharacterCommand command, [FromServices] CharacterHandler handler)
 {
     return((GenericCommandResponse)await handler.Handle(command));
 }