public async Task <GenericCommandResult <ClientEntity> > Repprove([FromServices] IClientHandler handler, [FromBody] RepproveClientCommand command) { var result = (GenericCommandResult <ClientEntity>) await handler.HandleAsync(command); return(result); }
public RepproveClientHandlerTests() { _repository = Substitute.For <IClientRepository>(); _handler = new ClientHandler(_repository); _commandWithoutId = _fixture .Build <RepproveClientCommand>() .Without(x => x.Id) .Create(); }
public RepproveClientCommandTests() { _commandWithoutId = _fixture .Build <RepproveClientCommand>() .With(x => x.Id, 0) .Create(); _commandWithId = _fixture .Build <RepproveClientCommand>() .With(x => x.Id, _fixture.Create <int>()) .Create(); }
public async Task <ICommandResult> HandleAsync(RepproveClientCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult <ClientEntity>(false, command.Notifications)); } var client = await _repository.GetAsync(command.Id); client.SetRepproved(); await _repository.UpdateAsync(client); return(new GenericCommandResult <ClientEntity>(true, client)); }