コード例 #1
0
        public ActionResult Create(CreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                BankAccount bankAccount = new BankAccount
                {
                    Name = model.Name,
                    Balance = model.Balance
                };

                bankAccountRepository.InsertBankAccount(bankAccount);

                Fund fund = new Fund
                {
                    Name = "What's Left",
                    Balance = bankAccount.Balance,
                    BankAccountId = bankAccount.BankAccountId
                };

                fundRepository.InsertFund(fund);

                return RedirectToAction("Index");
            }
            else
            {
                return View(model);
            }
        }
コード例 #2
0
        public ViewResult Create()
        {
            CreateViewModel model = new CreateViewModel()
            {
                Name = String.Empty,
                Balance = 0,
            };

            return View(model);
        }