private void BuidCreateBankAccountCommand() { _createBankAccountCommand = new CreateBankAccountCommand(); _createBankAccountCommand.BankName = "Banco"; _createBankAccountCommand.Agency = "1234"; _createBankAccountCommand.AccountNumber = "123456-7"; }
public IActionResult CreateBankAccount([FromBody] CreateBankAccountCommand command) { var result = _accountService.CreateAccount(command.UserId); if (result != CreateAccountResult.Success) { return(BadRequest(result.GetStringValue())); } return(Ok(result.GetStringValue())); }
public async Task CreateAccountShouldFalse() { // Arrange var command = new CreateBankAccountCommand(); // Action var commandResult = await _sut.Handle(command, new CancellationToken()); // Assert commandResult.IsSuccess.Should().BeFalse(); }
public async Task <IActionResult> Create([FromForm] CreateBankAccountCommand command) { if (ModelState.IsValid) { BankAccount taskReturn = await Mediator.Send(command); return(Ok(new BankAccountsResponse(nameof(BankAccount), taskReturn, taskReturn.statusCode, _baseLocalizer, _localizer))); } else { return(BadRequest(ModelState)); } }
public async Task <ActionResult> CreateBankAccount([FromBody] CreateBankAccountCommand command, CancellationToken cancellationToken) { if (command == null || String.IsNullOrWhiteSpace(command.Name)) { return(BadRequest()); } // TODO: Create event. // TODO: Store event. // TODO: Relay event. await Task.CompletedTask; return(NoContent()); }
public void AccountMappingProfileShouldValid() { // Arrange var profile = new AccountMappingProfile(); var configuration = new MapperConfiguration(cfg => cfg.AddProfile(profile)); var mapper = new Mapper(configuration); var source = new CreateBankAccountCommand() { Name = "NuConta", InitialValue = 154 }; // Action var destination = mapper.Map <CreateBankAccountCommand, BankAccount>(source); // Assert using (new AssertionScope()) { destination.Name.Should().Be(source.Name); destination.Balance.Should().Be(source.InitialValue); } }
public ICommandResult Create([FromBody] CreateBankAccountCommand command) { return(_handler.Handle(command)); }
public async Task <ActionResult> Create(CreateBankAccountCommand createAccountCommand) => await SendCommand(createAccountCommand);