public ActionResult Edit(int id, EditBrokerageAccountVm editBrokerageAccountVm)
        {
            var brokerageAccount = BrokerageAccountService.GetBrokerageAccountForActiveUser(id);
            if (brokerageAccount == null)
            {
                this.FlashError("Invalid brokerage account requested. Please try again.", "Index", "BrokerageAccounts");
                return RedirectToAction("Index", "BrokerageAccounts", new { area = "" });
            }

            if (ModelState.IsValid)
            {
                bool accountNumberDiff = brokerageAccount.AccountNumber != editBrokerageAccountVm.AccountNumber;
                if (!accountNumberDiff ||
                    (!BrokerageAccountService.ValidateDuplicateAccountNumber(editBrokerageAccountVm.AccountNumber, editBrokerageAccountVm.BrokerageId)))
                {
                    bool updatedAccount = BrokerageAccountService.UpdateBrokerageAccount(editBrokerageAccountVm, brokerageAccount);

                    if (updatedAccount)
                    {
                        this.FlashSuccess("Successfully updated the brokerage account.", "Details", "BrokerageAccounts");
                        return RedirectToAction("Details", "BrokerageAccounts", new { area = "", id = brokerageAccount.Id });
                    }
                    this.FlashError("Could not update the brokerage account. Please try again.", "Edit", "BrokerageAccounts");
                }
                else
                {
                    ModelState.AddModelError("AccountNumber", "The provided account number already exists.");
                    this.FlashError("The provided account number already exists.", "Edit", "BrokerageAccounts");
                }

            }

            var brokerageList = BrokerageAccountService.GetBrokerageList();
            ViewBag.BrokerageId = new SelectList(brokerageList, "Id", "Title", brokerageAccount.BrokerageId);

            return View(editBrokerageAccountVm);
        }
        public bool UpdateBrokerageAccount(EditBrokerageAccountVm editBrokerageAccountVm, BrokerageAccount brokerageAccount)
        {
            if (editBrokerageAccountVm.UserId == brokerageAccount.UserId && editBrokerageAccountVm.Id == brokerageAccount.Id)
            {
                brokerageAccount.AccountNumber = editBrokerageAccountVm.AccountNumber;
                brokerageAccount.BrokerageId = editBrokerageAccountVm.BrokerageId;
                brokerageAccount.IsRetirement = editBrokerageAccountVm.IsRetirement;

                return BrokerageAccountRepository.UpdateBrokerageAccount(brokerageAccount).OperationSuccessStatus;
            }

            return false;
        }
        //
        // GET: /BrokerageAccounts/Edit/5
        public ActionResult Edit(int id)
        {
            var brokerageAccount = BrokerageAccountService.GetBrokerageAccountForActiveUser(id);
            if (brokerageAccount == null)
            {
                this.FlashError("Invalid brokerage account requested. Please try again.", "Index", "BrokerageAccounts");
                return RedirectToAction("Index", "BrokerageAccounts", new { area = "" });
            }

            ViewBag.BrokerageAccount = brokerageAccount;

            var brokerageList = BrokerageAccountService.GetBrokerageList();
            ViewBag.BrokerageId = new SelectList(brokerageList, "Id", "Title", brokerageAccount.BrokerageId);

            var editBrokerageAccountVm = new EditBrokerageAccountVm
            {
                IsRetirement = brokerageAccount.IsRetirement,
                Title = brokerageAccount.Title,
                BrokerageId = brokerageAccount.BrokerageId,
                AccountNumber = brokerageAccount.AccountNumber,
                UserId = brokerageAccount.UserId,
                Id = brokerageAccount.Id
            };

            return View(editBrokerageAccountVm);
        }