public ActionResult Add(AddBrokerageAccountVm addBrokerageAccountVm)
        {
            if (ModelState.IsValid)
            {
                if (!BrokerageAccountService.ValidateDuplicateAccountNumber(addBrokerageAccountVm))
                {
                    int brokerageAccountId = BrokerageAccountService.CreateBrokerageAccount(addBrokerageAccountVm);

                    if (brokerageAccountId > 0)
                    {
                        this.FlashSuccess("Successfully created the brokerage account.", "Details", "BrokerageAccounts");
                        return RedirectToAction("Details", "BrokerageAccounts", new { area = "", id = brokerageAccountId });
                    }
                    this.FlashError("Could not create the brokerage account. Please try again.", "Add", "BrokerageAccounts");
                }
                else
                {
                    ModelState.AddModelError("AccountNumber", "The provided brokerage account already exists.");
                    this.FlashError("The provided brokerage account already exists.", "Add", "BrokerageAccounts");
                }
            }

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

            return View(addBrokerageAccountVm);
        }
        public int CreateBrokerageAccount(AddBrokerageAccountVm addBrokerageAccountVm)
        {
            var brokerageAccount = new BrokerageAccount
            {
                Title = addBrokerageAccountVm.Title,
                IsRetirement = addBrokerageAccountVm.IsRetirement,
                AccountNumber = addBrokerageAccountVm.AccountNumber,
                UserId = ActiveUserService.GetUserId(),
                BrokerageId = addBrokerageAccountVm.BrokerageId
            };

            DbOperationStatus opStatus = BrokerageAccountRepository.InsertBrokerageAccount(brokerageAccount);
            if (opStatus.OperationSuccessStatus)
            {
                return opStatus.AffectedIndices.First();
            }
            return -1;
        }
 public bool ValidateDuplicateAccountNumber(AddBrokerageAccountVm addBrokerageAccountVm)
 {
     return ValidateDuplicateAccountNumber(addBrokerageAccountVm.AccountNumber, addBrokerageAccountVm.BrokerageId);
 }