public async void Should_CreateAccountAsync_Valid() { var newAccountEntity = new AccountEntity { ProfileId = "999" }; var newCreatedAccountEntity = await _service.CreateAccountAsync(newAccountEntity); Assert.NotNull(newCreatedAccountEntity); }
public async Task <IActionResult> CreateAccount([FromBody] AccountCreateDto createDto) { if (!ModelState.IsValid) { return(BadRequest()); } try { await _accountsService.CreateAccountAsync(createDto); return(Ok()); } catch (Exception) { return(BadRequest()); } }
public async Task <IAccountModel?> ProcessTransactionCheckedEventAsync(IAccountModel accountModel) { var existingAccount = await _accountsService.GetAccountByIdAsync(accountModel.Id.ToGuid()); if (existingAccount != null) { if (accountModel.IsBlocked()) { existingAccount.SetBlocked(); } var updatedAccount = await _accountsService.UpdateAccountAsync(existingAccount); return(updatedAccount?.ToAccountModel <AccountDto>()); } var createdAccount = await _accountsService.CreateAccountAsync(accountModel.ToAccountEntity()); return(createdAccount?.ToAccountModel <AccountDto>()); }
public async Task <AccountDto?> CreateNewAccountAsync(string profileId) { if (!string.IsNullOrEmpty(profileId)) { var accountRequest = new AccountDto { ProfileId = profileId }; accountRequest.SetPending(); var newAccount = await _accountsService.CreateAccountAsync(accountRequest.ToAccountEntity()); await _publishEndpoint.Publish(newAccount?.ToAccountEvent <AccountCreatedEvent>()); await _publishEndpoint.Publish(newAccount?.ToAccountEvent <AccountCheckCommand>()); return(newAccount?.ToAccountModel <AccountDto>()); } return(null); }