public ResponsePM GetSymbolData(string symbol) { External_DatabaseEntities db = new External_DatabaseEntities(); var list = db.StockDatas.ToList(); var price1 = list.Where(s => s.Symbol == symbol).Select(s => s.MarketPrice); int price = price1.First(); var name1 = list.Where(s => s.Symbol == symbol).Select(s => s.Name); string name = name1.First(); ResponsePM obj = new ResponsePM(); obj.Name = name; obj.Price = price; obj.Symbol = symbol; return(obj); }
public List <ResponsePM> GetWholeData() { External_DatabaseEntities dbObj = new External_DatabaseEntities(); var stockList = dbObj.StockDatas.ToList(); List <ResponsePM> listObj = new List <ResponsePM>(); foreach (var stock in stockList) { ResponsePM responseObj = new ResponsePM(); responseObj.Symbol = stock.Symbol; responseObj.Name = stock.Name; responseObj.Price = stock.MarketPrice; listObj.Add(responseObj); } return(listObj); }