public async Task <CreateAccountResponse> ExecuteCommandAsync(AccountCreateCommand command) { var newAccountId = CreateRandomAccountId(); while (await _accountRepository.AccountExistsAsync(newAccountId) == false) { newAccountId = CreateRandomAccountId(); } var newAccount = new Account(newAccountId, command.Name, command.StartingBalance); var created = await _accountRepository.AddNewAccountAsync(newAccount); if (created == false) { return(null); } return(new CreateAccountResponse(newAccountId)); }
public async Task <IActionResult> Post([FromBody] AccountCreateCommand command) { var id = await _mediator.Send(command); return(await Get(id)); }