/// <summary> /// Retrieves the and save semester data. /// </summary> /// <param name="semesterID">The semester ID.</param> /// <returns></returns> private Semester RetrieveAndSaveSemesterData(string semesterID, bool isArchiveData = false) { Semester semester = new Semester(); semester.Id = semesterID.Remove(0, 5).Replace(" ", string.Empty); semester.Name = semesterID.Remove(0, 5); Dictionary<string, string> departmentsValues = RetrieveDepartmentList(); foreach(KeyValuePair<string, string> departmentValue in departmentsValues) { Department department = new Department(); department.DepartmentID = departmentValue.Key; department.Name = departmentValue.Value; department.SemesterID = semester.Id; string content = string.Empty; if(isArchiveData) { content = RetrieveRawCourseData(semesterID, department.DepartmentID, "http://www3.mnsu.edu/courses/selectformArchive.asp"); } else { content = RetrieveRawCourseData(semesterID, department.DepartmentID); } ParseRawCourseData(content, department); //Store Department to database if(department.CourseIds.Count > 0) { m_RavenSession.Store(department); m_RavenSession.Advanced.AddCascadeDeleteReference(department, department.CourseIds.ToArray()); semester.DepartmentIds.Add(department.Id); } } //Store Semester to database m_RavenSession.Store(semester); m_RavenSession.Advanced.AddCascadeDeleteReference(semester, semester.DepartmentIds.ToArray()); //Save changes to database m_RavenSession.SaveChanges(); return semester; }
/// <summary> /// Gets the semester by ID. /// </summary> /// <param name="semesterID">The semester ID.</param> /// <returns></returns> public Semester GetSemesterByID(string semesterID) { Semester item = new Semester(); if(!string.IsNullOrEmpty(semesterID)) { item = m_RavenSession.Load<Semester>(semesterID); } return item; }