public void GetCourseList() { DropDownListCourse.Items.Clear(); try { ListItem[] _listCourse = _inBloomApi.GetCourseBySchool(DropDownListSchool.SelectedItem.Value.ToString()); _user = (User)Session["UserDetail"]; if (_user.IsAdminUser || IsLeader()) { _inBloomApi.GetSectionByStaffIdAndSchoolId(dropDownListStaff.SelectedItem.Value, DropDownListSchool.SelectedItem.Value); //_sectionAndCourseOfferingId=> sectionid and courseofferingid ListItem[] _sectionAndCourseOfferingId = _inBloomApi.GetSectionAndCourseOfferingIdList(); ListItem[] _temp = new ListItem[_sectionAndCourseOfferingId.Count()]; ListItem[] _courseIdAndCourseOfferingId = new ListItem[_sectionAndCourseOfferingId.Count()]; for (int i = 0; i < _sectionAndCourseOfferingId.Count(); i++) { ListItem _course = _inBloomApi.GetCourseBySectionCourseOfferingId(_sectionAndCourseOfferingId[i].Value); _temp[i] = new ListItem(_course.Text, _course.Value); _courseIdAndCourseOfferingId[i] = new ListItem(_course.Value, _sectionAndCourseOfferingId[i].Value); } DropDownListCourse.Items.AddRange(_temp); Course course = new Course(_temp); Session["Course"] = course; Session["SectionAndCourseOfferingId"] = _sectionAndCourseOfferingId; Session["CourseIdAndCourseOfferingId"] = _courseIdAndCourseOfferingId; } else { if (!IsEducator()) { _inBloomApi.GetSectionByStaffIdAndSchoolId(dropDownListStaff.SelectedItem.Value, DropDownListSchool.SelectedItem.Value); } else { _inBloomApi.GetSectionListForLoginUser(); } ListItem[] _sectionAndCourseOfferingId = _inBloomApi.GetSectionAndCourseOfferingIdList(); ListItem[] _temp = new ListItem[_sectionAndCourseOfferingId.Count()]; ListItem[] _courseIdAndCourseOfferingId = new ListItem[_sectionAndCourseOfferingId.Count()]; if (_listCourse != null) { for (int i = 0; i < _sectionAndCourseOfferingId.Count(); i++) { ListItem _course = _inBloomApi.GetCourseBySectionCourseOfferingId(_sectionAndCourseOfferingId[i].Value); // check more than one course bool IsCoursePresent = false; for (int j = 0; j < _temp.Count(); j++) { if (_temp[j] != null) { if (_temp[j].Value == _course.Value) { IsCoursePresent = true; break; } } } if (IsCoursePresent) { } else { _temp[i] = new ListItem(_course.Text, _course.Value); } _courseIdAndCourseOfferingId[i] = new ListItem(_course.Value, _sectionAndCourseOfferingId[i].Value); //for (int Index = 0; Index < _listCourse.Count(); Index++) //{ // bool Find = _inBloomApi.IsSectionContainOfferingOfThisCourse(_sectionAndCourseOfferingId[i].Value, _listCourse[Index].Value); // if (Find) // { // _temp[i] = new ListItem(_listCourse[Index].Text, _listCourse[Index].Value); // _courseIdAndCourseOfferingId[i] = new ListItem(_listCourse[Index].Value, _sectionAndCourseOfferingId[i].Value); // break; // } //} } //DropDownListCourse.Items.AddRange(_listCourse); //Course course = new Course(_listCourse); //Session["Course"] = course; for (int i = 0; i < _temp.Count(); i++) { if (_temp[i] != null) DropDownListCourse.Items.Add(_temp[i]); } // DropDownListCourse.Items.AddRange(_temp); Course course = new Course(_temp); Session["Course"] = course; Session["SectionAndCourseOfferingId"] = _sectionAndCourseOfferingId; Session["CourseIdAndCourseOfferingId"] = _courseIdAndCourseOfferingId; } else { Session["Course"] = null; } } } catch (Exception ex) { } }
public void GetCourseListNew() { try { _user = (User)Session["UserDetail"]; DropDownListCourse.Items.Clear(); ListItem[] _sectionList = null; if (_user.IsAdminUser || IsLeader()) { _sectionList = _inBloomApi.GetSectionByStaffIdAndSchoolId(dropDownListStaff.SelectedItem.Value, DropDownListSchool.SelectedItem.Value); } else { _sectionList = _inBloomApi.GetSectionListForLoginUser(); } ListItem[] _sectionAndCourseOfferingId = _inBloomApi.GetSectionAndCourseOfferingIdList(); ListItem[] _temp = new ListItem[_sectionAndCourseOfferingId.Count()]; ListItem[] _courseAndSectionIdTemp = new ListItem[_sectionAndCourseOfferingId.Count()]; ListItem[] _sectionAndCourseIdTemp = new ListItem[_sectionAndCourseOfferingId.Count()]; for (int i = 0; i < _sectionAndCourseOfferingId.Count(); i++) { ListItem _course = _inBloomApi.GetCourseBySectionCourseOfferingId(_sectionAndCourseOfferingId[i].Value); bool IsPresent = false; for (int j = 0; j < _temp.Count(); j++) { if (_temp[j] != null) { if (_temp[j].Value == _course.Value) { IsPresent = true; break; } } } if (!IsPresent) { _temp[i] = new ListItem(_course.Text, _course.Value); } _courseAndSectionIdTemp[i] = new ListItem(_course.Value, _sectionList[i].Value); _sectionAndCourseIdTemp[i] = new ListItem(_sectionList[i].Value, _course.Value); } for (int i = 0; i < _temp.Count(); i++) { if (_temp[i] != null) { DropDownListCourse.Items.Add(_temp[i]); } } //DropDownListCourse.Items.AddRange(_temp); Course course = new Course(_temp); Session["Course"] = course; Session["CourseAndSectionIdTemp"] = _courseAndSectionIdTemp; Session["SectionAndCourseIdTemp"] = _sectionAndCourseIdTemp; } catch (Exception Ex) { } }