/// <summary> /// GetCourseSections - Gets the sections offered for a specific course from the search results. /// </summary> /// <param name="courseId">A string representing a course ID such as "ENGL&101"</param> /// <param name="classes">The vw_CLASS_D list search results.</param> /// <returns>A list of SectionModel objects.</returns> public List<SectionModel> GetCourseSections(string courseId, List<vw_CLASS_D> classes) { List<SectionModel> sections = new List<SectionModel>(); string[] courseIds = new string[] { courseId.TrimEnd(), courseId.TrimEnd() + HP_JERRYRIGGED_CANCELLED_INDICATOR }; double credits = 0; var courseSections = classes.Where(c => courseIds.Contains(c.COURSE_ID.TrimEnd())).ToList<vw_CLASS_D>(); foreach (var item in courseSections) { SectionModel sect = new SectionModel(); //if the course if marked as cancelled... if (item.SECT_STAT.Contains(SCHEDULE_CHANGE_CANCELLED)) { //we're not going to process anything... sect.Section = item.SECT.TrimEnd(); sect.ContinuousSequence = false; sect.CourseDates = ""; sect.CourseDatesDifferentThanQuarter = false; sect.CulturalDiversity = false; sect.Days = ""; sect.Early = false; sect.FeeInformation = ""; sect.Footnote = ""; sect.Hybrid = false; sect.Instructor = SCHEDULE_CHANGE_CANCELLED_TEXT; sect.ItemNumber = sect.ItemNumber = item.CLASS_ID.Substring(0, 4); sect.Late = false; sect.Location = ""; sect.NoOnlineRegistration = false; sect.Online = false; sect.Times = ""; sect.VariableCredit = (item.VAR_CR.TrimEnd() == HP_YES_VALUE); //if the credit field has a value... if (item.CR.HasValue) { if (Int32.Parse(item.CR.Value.ToString()) > 0) { credits = (Int32.Parse(item.CR.Value.ToString()) * 0.1); //if the course if a variable credit course... if (sect.VariableCredit) { //modify the display to be "MAX " + the number of credits. sect.Credits = MAX_CREDITS_TEXT + credits.ToString(); } else { //if not, we just return the credits as a string. sect.Credits = credits.ToString(); } } else { sect.Credits = HP_NO_CREDITS_VALUE; } sect.Credits = sect.Credits + CREDITS_DISPLAY_TEXT; } //process section changed... sect.ScheduleChanged = (item.SCHD_CHNG_DATE != null && item.SCHD_CHNG_DATE != 0); if (sect.ScheduleChanged && item.SCHD_CHNG_DATE.HasValue) { sect.ScheduleChangeDate = GetSectionDateText(item.SCHD_CHNG_DATE.ToString()); sect.ScheduleChangeText = SECTION_CHANGE_DISPLAY_TEXT + sect.ScheduleChangeDate + ": " + GetScheduleChangeText(item.SCHD_CHNG); } } else { //Continuing/Sequential Classes //C A open-entry/open-exit course section in which a student can enroll, begin, and end instruction at any time. //S Any course not classified as continuous. sect.ContinuousSequence = (item.CONT_SEQ.TrimEnd() == HP_CONTINUOUS_SEQUENCE); //variable credit course... sect.VariableCredit = (item.VAR_CR.TrimEnd() == HP_YES_VALUE); //if the credit field has a value... if (item.CR.HasValue) { if (Int32.Parse(item.CR.Value.ToString()) > 0) { credits = (Int32.Parse(item.CR.Value.ToString()) * 0.1); //if the course if a variable credit course... if (sect.VariableCredit) { //modify the display to be "MAX " + the number of credits. sect.Credits = MAX_CREDITS_TEXT + credits.ToString(); } else { //if not, we just return the credits as a string. sect.Credits = credits.ToString(); } } else { sect.Credits = HP_NO_CREDITS_VALUE; } sect.Credits = sect.Credits + CREDITS_DISPLAY_TEXT; } //if the course title includes ":CD", it is a cultural diversity course. sect.CulturalDiversity = (item.COURSE_TITLE.Contains(CULTURAL_DIVERSITY_INDICATOR)); //Set the Course Days display text sect.Days = GetCourseDays(item.DAY_CD); //if the course offering has an associated fee, we need to //get the approriate fee information. if (item.CLASS_FEE.HasValue) { sect.FeeInformation = GetSectionFeeAmount(item.CLASS_FEE1.Value, item.CLASS_FEE2.Value, item.FND_SRC, item.CLASS_FEE_CD1, item.CLASS_FEE_CD2, credits, item.YRQ); } else { sect.FeeInformation = string.Empty; } //Load the display text for any course footnotes. sect.Footnote = GetCourseFootnote(item.FOOTNOTE_1) + " " + GetCourseFootnote(item.FOOTNOTE_2); //If the BRANCH field contains "HY", the course if a hybrid course. sect.Hybrid = (item.BRANCH.TrimEnd() == HP_HYBRID); //get the instructor name information as appropriate. if (item.INSTR_NAME.TrimEnd() == "" || item.INSTR_NAME == null) { sect.Instructor = ""; } else { sect.Instructor = item.INSTR_NAME.TrimEnd(); //GetInstructorName(item.INSTR_ID);// (item.INSTR_NAME.TrimEnd()); } //Get the Item Number sect.ItemNumber = item.CLASS_ID.Substring(0, 4); //Get the location display //item.R //LOCATION //e.g. MLT0103 sect.Location = GetSectionLocationDisplay(item.ROOM_LOC); string locPrint = item.ROOM_LOC.Trim(); if (locPrint != null && locPrint != "") { string bldgVal = locPrint.Substring(0, 3); string roomVal = locPrint.Substring(3, locPrint.Length - 3); sect.LocationPrint = bldgVal + " " + roomVal.TrimStart(HP_LOCATION_LEADING_ZERO); } else { sect.LocationPrint = ""; } //Check if the course allows online registration. sect.NoOnlineRegistration = (item.ALLOW_TTONE_REG.TrimEnd() == HP_NO_VALUE); //if the BRANCH field equals "OL", it is an online course. sect.Online = (item.BRANCH.TrimEnd() == HP_ONLINE); ; //handle schedule change... sect.ScheduleChanged = (item.SCHD_CHNG_DATE != null && item.SCHD_CHNG_DATE != 0); if (sect.ScheduleChanged && item.SCHD_CHNG_DATE.HasValue) { sect.ScheduleChangeDate = GetSectionDateText(item.SCHD_CHNG_DATE.ToString()); sect.ScheduleChangeText = SECTION_CHANGE_DISPLAY_TEXT + sect.ScheduleChangeDate + ": " + GetScheduleChangeText(item.SCHD_CHNG); } //get the course section. sect.Section = item.SECT; //if the start and end dates have values... if (item.STRT_DATE.HasValue && item.STRT_DATE.HasValue) { //the start date is different than the quarter dates... sect.CourseDatesDifferentThanQuarter = true; int sDate = 0; int eDate = 0; if (item.STRT_DATE.HasValue && item.STRT_DATE.Value > 0) { sDate = item.STRT_DATE.Value; } if (item.END_DATE.HasValue && item.END_DATE.Value > 0) { eDate = item.END_DATE.Value; } sect.CourseDates = GetCourseDateInformation(sDate.ToString(), eDate.ToString()); } //if there are values for start and end times... if (item.STRT_TIME != null && item.END_TIME != null) { //get the start and end time display. sect.Times = GetSectionTimeDisplay(item.STRT_TIME, item.END_TIME); } else { sect.Times = ""; } //Determine if the course is a late course or an early course. sect.Late = (item.StartTime > DateTime.Parse(START_TIME_LATE)); sect.Early = (item.StartTime < DateTime.Parse(START_TIME_EARLY)); //check for any "Also Meets" team taugh courses. sect.AlsoMeets = GetSectionAlsoMeets(item.CLASS_ID.TrimEnd()); sect.HasAlsoMeets = (sect.AlsoMeets.Count() > 0); } sections.Add(sect); } return sections.OrderBy(s=>s.ItemNumber).ToList<SectionModel>(); }
/// <summary> /// GetSectionAlsoMeets - returns a section model for a course offering, to provide any "Also Meets" /// value for a course found in the INSTR_ROOM_D of the ClassSchedule database. This is common for /// courses that are team taught and/or have alternate meeting information. /// </summary> /// <param name="classID">A string value representing a Class ID (item number + Year Quarter).</param> /// <returns>A SectionModel object list.</returns> public List<SectionModel> GetSectionAlsoMeets(string classID) { List<SectionModel> models = new List<SectionModel>(); using (HPSADataContext ctx = new HPSADataContext()) { var items = ctx.INSTR_ROOM_Ds.Where(s => s.CLASS_ID == classID).ToList<INSTR_ROOM_D>(); foreach (var item in items) { SectionModel sect = new SectionModel(); sect.Days = GetCourseDays(item.DAY_CD); if (item.INSTR_NAME.TrimEnd() == "" || item.INSTR_NAME == null) { sect.Instructor = ""; } else { sect.Instructor = item.INSTR_NAME.TrimEnd(); //GetInstructorName(item.INSTR_ID);// (item.INSTR_NAME.TrimEnd()); } sect.Location = GetSectionLocationDisplay(item.ROOM_LOC); if (item.STRT_TIME != null && item.END_TIME != null) { sect.Times = GetSectionTimeDisplay(item.STRT_TIME, item.END_TIME); } else { sect.Times = ""; } models.Add(sect); } } return models; }