public void GetShifts() { DateTime[] range = GetDay(Calendar1.SelectedDate); sqlController sqc = new sqlController(); List <SqlParameter> sqlParams = new List <SqlParameter>(); sqlParams.Add(new SqlParameter("@Start", range[0])); sqlParams.Add(new SqlParameter("@End", range[1])); DataTable table = sqc.GetShifts(sqlParams); sqlParams.Clear(); DataTable empTable = sqc.GetScheduleNames(); foreach (DataRow row in empTable.Rows) { var s = new Employee(row["Name"].ToString()); s.Title = row["Job"].ToString(); if (!empList.Any(x => x.Name == row["Name"].ToString())) { empList.Add(s); } fullList.Add(s); } lstShifts = new List <Shift>(); foreach (DataRow row in table.Rows) { Employee Employee = empList.First(x => x.Name == row["Name"].ToString()); Shift shift = new Shift(); shift.ID = (int)row["ID"]; shift.Name = row["Name"].ToString().Trim(); shift.Start = (DateTime)row["Start_Time"]; shift.End = (DateTime)row["End_Time"]; shift.Job = row["Job"].ToString().Trim(); //Employee.Title = row["Job"].ToString().Trim(); shift.ShiftName = row["Shift"].ToString().Trim(); Employee.Schedule.Shifts.Add(shift); lstShifts.Add(shift); } Session["Shifts"] = null; Session["Schedule"] = null; Session["Full"] = null; Session["Shifts"] = lstShifts; Session["Schedule"] = empList; Session["Full"] = fullList; Get_ScheduleNames(); }