public ActionResult AddSell(AddSellTransactionVm addSellTransactionVm)
        {
            if (ModelState.IsValid)
            {
                var brokerageAccount =
                    BrokerageAccountService.GetBrokerageAccount(addSellTransactionVm.BrokerageAccountId);
                // Did we find the requested account and does it belong to the active user?
                if (brokerageAccount == null || brokerageAccount.UserId != ActiveUserService.GetUserId())
                {
                    this.FlashError("Please ensure the requested brokerage account is setup under the active user and try again.", "Index", "BrokerageAccounts");
                    return(RedirectToAction("Index", "BrokerageAccounts", new { area = "" }));
                }

                int sellTransactionId = SellTransactionService.CreateSellTransaction(addSellTransactionVm);

                if (sellTransactionId > 0)
                {
                    this.FlashSuccess("Successfully created the sell transaction.", "SellDetails", "StockTransactions");
                    return(RedirectToAction("SellDetails", "StockTransactions", new { area = "", id = sellTransactionId }));
                }
                this.FlashError("Could not create the sell transaction. Please try again.", "AddSell", "StockTransactions");
            }

            foreach (var transactionMatch in addSellTransactionVm.MatchingPurchaseTransactions)
            {
                transactionMatch.PurchaseTransaction =
                    PurchaseTransactionService.GetPurchaseTransaction(transactionMatch.PurchaseTransactionId);
            }

            var brokerageAccountList = BrokerageAccountService.GetBrokerageAccountListForActiveUser();

            // Does the active user have any brokerage accounts setup?
            if (!brokerageAccountList.Any())
            {
                this.FlashError("Please ensure a brokerage account is setup and try again.", "Index", "BrokerageAccounts");
                return(RedirectToAction("Index", "BrokerageAccounts", new { area = "" }));
            }

            ViewBag.BrokerageAccountId = new SelectList(brokerageAccountList, "Id", "Title");

            var stockList = PurchaseTransactionService.GetStocksWithOpenPositionsForBrokerageAccount(addSellTransactionVm.BrokerageAccountId);

            ViewBag.SecurityId = new SelectList(stockList, "Id", "Title", addSellTransactionVm.SecurityId);

            return(View(addSellTransactionVm));
        }