public async Task <AccountInsertResult> InsertAsync(AccountInsertArgs args) { AccountInsertResult logicResult = new AccountInsertResult(); try { Account entity = args.Account.ToEntity(); entity.MetaCreatedTimeCode = DateTime.UtcNow.ToSuperEpochUtc(); entity.MetaModifiedTimeCode = DateTime.UtcNow.ToSuperEpochUtc(); _ = _context.Add(entity); _ = await _context.SaveChangesAsync() .ConfigureAwait(false); } catch (Exception ex) { logicResult.Exception = ex; } return(logicResult); }
public async Task <AccountCreateResult> Handle(AccountCreateCommand command, CancellationToken cancellationToken) { AccountCreateResult logicResult = new AccountCreateResult(); try { Account account = Account.Create(command.Args); AccountInsertArgs accountInsertArgs = new AccountInsertArgs { Account = account }; AccountInsertResult accountInsertResult = await _accountRepository.InsertAsync(accountInsertArgs) .ConfigureAwait(false); accountInsertResult.EnsureSuccess(); logicResult.Result = accountInsertResult.Result; } catch (Exception ex) { logicResult.Exception = ex; } return(logicResult); }