public async Task <AccountRemoveResult> RemoveAsync(AccountRemoveArgs args) { AccountRemoveResult logicResult = new AccountRemoveResult(); try { Account existingAccount = await _context.Set <Account>().Where(x => x.AccountId == args.AccountId) .FirstAsync() .ConfigureAwait(false); _context.Entry(existingAccount).State = EntityState.Deleted; _ = await _context.SaveChangesAsync() .ConfigureAwait(false); } catch (Exception ex) { logicResult.Exception = ex; } return(logicResult); }
public async Task <AccountDeleteResult> Handle(AccountDeleteCommand command, CancellationToken cancellationToken) { AccountDeleteResult logicResult = new AccountDeleteResult(); try { Guid accountId = Account.Delete(command.Args); AccountRemoveArgs accountRemoveArgs = new AccountRemoveArgs { AccountId = accountId }; AccountRemoveResult accountRemoveResult = await _accountRepository.RemoveAsync(accountRemoveArgs) .ConfigureAwait(false); accountRemoveResult.EnsureSuccess(); logicResult.Result = accountRemoveResult.Result; } catch (Exception ex) { logicResult.Exception = ex; } return(logicResult); }