// This method accepts username and password parameters and returns a list of all the user's // portfolio/ company information converted from the API. public async Task <List <ListProperties> > PortFolioList(string username, string password) { AccessDB accessDB = new AccessDB(); string conStr = ConfigurationManager.ConnectionStrings["ConStrs"].ConnectionString; Task <List <ListProperties> > t2 = Task.Factory.StartNew <List <ListProperties> >(() => { List <ListProperties> portFolio = new List <ListProperties>(); List <string> Jsons = new List <string>(); List <Person> people = new List <Person>(); string Json = String.Empty; using (SqlConnection con = new SqlConnection(conStr)) { con.Open(); string userID = string.Empty; people = accessDB.Login_Check(username, password, con); foreach (Person p in people) { userID = p.UserID; } foreach (PortFolio cs in accessDB.ListPortFolio(userID, con)) { string url = string.Format("https://api.iextrading.com/1.0/stock/{0}/quote", cs.Name); using (WebClient port_folio = new WebClient()) { Jsons.Add(port_folio.DownloadString(url)); Json = sp.JsonPortFolioCreator(Jsons); portFolio = JsonConvert.DeserializeObject <List <ListProperties> >(Json); } } } return(portFolio); }); await t2; return(t2.Result); }