예제 #1
0
        public decimal GetTotalShares(string ticker)
        {
            int total = 0;

            try
            {
                CTransaction t = new CTransaction();
                total = t.GetTotalShares(ticker);
            }
            catch (Exception ex)
            {
                CErrorLog err = new CErrorLog();
                err.LogError(ex.Message);
                throw ex;
            }
            return(total);
        }
예제 #2
0
        public void Load()
        {
            try
            {
                //we will need to pass in the userID here to be able to limit the user to only see their list of stocks. see below *

                WealthDataContext oDc = new WealthDataContext();

                var results = (from s in oDc.tblStocks
                               join u in oDc.tblUsers on s.UserId equals u.Id
                               where u.Id == CLogin.UserLoggedIn
                               orderby s.Ticker
                               // * where s.userid == u.userId
                               select new
                {
                    s.Id,
                    custId = s.UserId,
                    s.Ticker,
                    s.CurrentPricePerShare,
                }).ToList();

                foreach (var stock in results)
                {
                    CStock       oStock = new CStock();
                    CTransaction t      = new CTransaction();
                    oStock.TotalPerTick = t.GetTotal(stock.Ticker);
                    oStock.TotalShares  = t.GetTotalShares(stock.Ticker);
                    oStock.Id           = stock.Id;
                    oStock.Ticker       = stock.Ticker;
                    oStock.Price        = GetPrice(stock.Ticker);
                    Add(oStock);
                }
            }
            catch (Exception ex)
            {
                CErrorLog err = new CErrorLog();
                err.LogError(ex.Message);
                throw ex;
            }
        }