private List <RoosterItem> ReadTables(DataTable dataTable) { List <RoosterItem> roosterItems = new List <RoosterItem>(); foreach (DataRow dr in dataTable.Rows) { RoosterItem roosterItem = new RoosterItem() { Description = (String)dr["Description"].ToString(), First_Name = (String)dr["First_Name"].ToString(), Last_Name = (String)dr["Last_Name"].ToString(), StartTime = (TimeSpan)dr["startTime"], EndTime = (TimeSpan)dr["endTime"], Date = (DateTime)dr["Date"] }; roosterItems.Add(roosterItem); } return(roosterItems); }
public List <RoosterItem> GetRoosterItems() { try { List <RoosterItem> roosterItems = activity_db.Db_Get_All_RoosterItems(); return(roosterItems); } catch (Exception) { // something went wrong connecting to the database, so we will add a fake student to the list to make sure the rest of the application continues working! List <RoosterItem> roosterItems = new List <RoosterItem>(); RoosterItem a = new RoosterItem(); a.Description = "Fout"; a.First_Name = "Fout"; a.Last_Name = "Fout"; a.StartTime = TimeSpan.MinValue; a.EndTime = TimeSpan.MinValue; a.Date = DateTime.Now; return(roosterItems); } }