コード例 #1
0
        public ActionResult Create(BankAccountEdit bankAccountEdit)
        {
            ModelState.Merge(bankAccountEdit.Validate(Db));

            if (ModelState.IsValid)
            {
                int[] userIds;
                bool saveOnlyUsers;
                BankAccount bankAccount = bankAccountEdit.GetModel(out userIds, out saveOnlyUsers);
                BankAccountCache.Insert(Db, bankAccount, userIds);
                return RedirectToAction("Index");
            }

            PopulateBankAccountType(bankAccountEdit.BankAccountType);
            PopulateCurrencyType(bankAccountEdit.CurrencyType);
            PopulateUserIds(bankAccountEdit.UserIds);

            return View(bankAccountEdit);
        }
コード例 #2
0
        public ActionResult Edit(BankAccountEdit bankAccountEdit)
        {
            ModelState.Merge(bankAccountEdit.Validate(Db));

            if (ModelState.IsValid)
            {
                int[] userIds;
                bool saveOnlyUsersOrToken;
                BankAccount bankAccount = bankAccountEdit.GetModel(out userIds, out saveOnlyUsersOrToken);
                bool success = BankAccountCache.Update(Db, userIds, saveOnlyUsersOrToken, ref bankAccount);
                if (!success)
                {
                    return RedirectToAccessDenied();
                }

                if (saveOnlyUsersOrToken)
                {
                    TempData[StatusMessageTempKey] = ViewResource.BankAccount_SaveOnlyUsers_Text;
                }

                return RedirectToAction("Index");
            }

            PopulateBankAccountType(bankAccountEdit.BankAccountType);
            PopulateCurrencyType(bankAccountEdit.CurrencyType);
            PopulateUserIds(bankAccountEdit.UserIds);

            return View(bankAccountEdit);
        }