public string CreateAccount(Bank bank, string name, string userName, string password) { if (bank.AccountHolders.Exists(Element => string.Equals(Element.UserName, userName)) == false) { Account account = new Account() { BankID = bank.ID.ToUpper(), Funds = 0, Transactions = new List <Transaction>() }; AccountHolder holder = new AccountHolder() { Password = password, UserName = userName, Name = name, BankID = bank.ID }; Tuple <Account, AccountHolder> AccountDetails = accountService.Create(account, holder, name); bank.Accounts.Add(AccountDetails.Item1); bank.AccountHolders.Add(AccountDetails.Item2); return(AccountDetails.Item1.ID); } else { return(null); } }
public async Task <ActionResult> Create(AccountViewModel vm) { var result = await _accountServices.Create(vm, GetAccount()); if (result.Status == Status.ok) { return(RedirectToAction(nameof(Index))); } else { ModelState.AddModelError("", "保存失败: " + result.Message); await Init(vm); return(View(vm)); } }