コード例 #1
0
        public async Task <GenericCommandResult <ClientEntity> > Approve([FromServices] IClientHandler handler,
                                                                         [FromBody] ApproveClientCommand command)
        {
            var result = (GenericCommandResult <ClientEntity>) await handler.HandleAsync(command);

            return(result);
        }
        public ApproveClientHandlerTests()
        {
            _repository = Substitute.For <IClientRepository>();
            _handler    = new ClientHandler(_repository);

            _commandWithoutId = _fixture
                                .Build <ApproveClientCommand>()
                                .Without(x => x.Id)
                                .Create();
        }
        public ApproveClientCommandTests()
        {
            _commandWithoutId = _fixture
                                .Build <ApproveClientCommand>()
                                .With(x => x.Id, 0)
                                .Create();

            _commandWithId = _fixture
                             .Build <ApproveClientCommand>()
                             .With(x => x.Id, _fixture.Create <int>())
                             .Create();
        }
コード例 #4
0
        public async Task <ICommandResult> HandleAsync(ApproveClientCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult <ClientEntity>(false, command.Notifications));
            }

            var client = await _repository.GetAsync(command.Id);

            client.SetApproved();
            await _repository.UpdateAsync(client);

            return(new GenericCommandResult <ClientEntity>(true, client));
        }