示例#1
0
 public AccountsController(IAccountQuery accountQuery, ICreateAccountAction updateAccountAction, ITransactionsForAccountQuery transactionQuery, IAccountByNameQuery accountByNameQuery)
 {
     _accountQuery        = accountQuery;
     _updateAccountAction = updateAccountAction;
     _transactionQuery    = transactionQuery;
     _accountByNameQuery  = accountByNameQuery;
 }
示例#2
0
        public async Task <IActionResult> PostAccount([FromBody] PasswordProvidingAccountDto account, [FromServices] ICreateAccountAction action)
        {
            Account result;

            try
            {
                result = await action.ToRunner(_context).ExecuteAsync(account);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (action.HasErrors)
                {
                    return(BizActionStatus(action));
                }

                if (AccountExists(account.Username))
                {
                    return(RestError(BusinessErrors.Account.UsernameAlreadyExists));
                }
                else
                {
                    throw;
                }
            }

            return(BizActionStatus(action, () => CreatedAtAction("GetAccount", new { id = account.AccountId }, Mapper.Map <AccountDto>(result))));
        }