Example #1
0
        //GET: StockTrades/SellStocksOptions
        // Loads the information to sell the stock
        public ActionResult SellStockOptions(int StockSaleID, int StockAccountID, int TradeID)
        {
            // Get the trade
            Trade CustomerTrade = db.Trades.Find(TradeID);

            SellStockTradeOptions SSTO = new SellStockTradeOptions
            {
                StockAccountID = StockAccountID,
                StockMarketID  = StockSaleID,
                TradeID        = TradeID,
                CustomerTrade  = CustomerTrade
            };

            return(View(SSTO));
        }
Example #2
0
        public ActionResult SellStockOptions([Bind(Include = "StockAccountID,StockMarketID,TradeID,Quantity,SaleDate")] SellStockTradeOptions SSTO)
        {
            // Get the stock to sell
            StockMarket StockToSell = db.StockMarket.Find(SSTO.StockMarketID);

            // Get the trade
            Trade CustomerTrade = db.Trades.Find(SSTO.TradeID);

            // Create a new sellstock object and send to the view
            SellStocksTrade SST = new SellStocksTrade
            {
                StockMarketID   = SSTO.StockMarketID,
                StockAccountID  = SSTO.StockAccountID,
                StockName       = StockToSell.CompanyName,
                QuantitySold    = SSTO.Quantity,
                Fee             = StockToSell.Fee,
                Profit          = ((StockToSell.StockPrice * SSTO.Quantity) - (CustomerTrade.PricePerShare * SSTO.Quantity)),
                SharesRemaining = (CustomerTrade.Quantity - SSTO.Quantity),
                TradeID         = SSTO.TradeID,
                SaleDate        = SSTO.SaleDate
            };

            return(View("SellStocks", SST));
        }