public void DegreeProgramsControllerCreateSuccessForward()
        {
            DegreeProgram temp   = createTempDegreeProgram();
            var           result = controller.Create(temp);

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
        }
        public ActionResult PostADegreeProgram(DegreeProgramVM vm, Guid DepId)
        {
            if (ModelState.IsValid)
            {
                var _DegreeType = _unitOfWork.Departments.GetADegreeTypeByName(vm.DegreeType);
                var model       = new DegreeProgram
                {
                    Name         = vm.Name,
                    Description  = vm.Description,
                    CreationDate = GetCurrentDate(),
                    DegreeType   = _DegreeType
                };

                _unitOfWork.Departments.AddADegreePorgram(model, DepId);
                _unitOfWork.Complete();
            }
            //Get a RecID of a DegreeProgram that is
            vm.RecID             = _unitOfWork.Departments.GetADgreeProgram(DepId, vm.Name).RecID;
            ViewBag.departmentId = DepId;


            //TODO: VM requires RecID

            return(PartialView("Degrees/_DegreeProgram", vm));
        }
        public void DegreeProgramsControllerEditSuccessForward()
        {
            DegreeProgram temp   = degreePrograms.Find(1);
            var           result = controller.Edit(temp, null, null);

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
        }
Example #4
0
 public RegNo(Session session, int year, DegreeProgram program, string rollno)
 {
     this.session = session;
     this.year    = year;
     this.program = program;
     this.rollno  = rollno;
 }
Example #5
0
        public void TestDegreeProgramConstructor()
        {
            CourseCollection courses = new CourseCollection();
            DegreeProgram    degree  = new DegreeProgram("Bachelors of Science", courses);

            Assert.AreEqual(degree.Name, "Bachelors of Science");
            Assert.AreEqual(degree.RequiredCourses, courses);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            DegreeProgram degreeProgram = db.DegreePrograms.Find(id);

            db.DegreePrograms.Remove(degreeProgram);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
        public JsonResult GetCourses(int id)
        {
            //DegreeProgram degreeProgram = degreePrograms.Find(id);
            DegreeProgram degreeProgram = _degreeProgramProducer.Get(new DegreeProgram()
            {
                ID = id
            });

            if (degreeProgram != null)
            {
                List <FlowchartCourse> results        = new List <FlowchartCourse>();
                Dictionary <int, int>  semesterOrders = new Dictionary <int, int>();
                for (int i = 1; i <= 8; i++)
                {
                    semesterOrders[i] = 0;
                }

                List <RequiredCourse> requirements = degreeProgram.requiredCourses.ToList();
                foreach (RequiredCourse req in requirements)
                {
                    FlowchartCourse pcourse = new FlowchartCourse();
                    pcourse.pcourseID   = req.ID;
                    pcourse.courseID    = req.courseID;
                    pcourse.courseTitle = req.course.courseCatalogNumber;
                    pcourse.courseName  = req.course.courseTitle;
                    int order = semesterOrders[req.semester];
                    pcourse.order = order;
                    semesterOrders[req.semester] = order + 1;
                    pcourse.semester             = req.semester;
                    pcourse.hours  = req.course.shortHours;
                    pcourse.prereq = new int[req.course.prerequisites.Count];
                    int place = 0;
                    foreach (PrerequisiteCourse prereq in req.course.prerequisites)
                    {
                        pcourse.prereq[place++] = prereq.prerequisiteCourseID;
                    }
                    results.Add(pcourse);
                }

                List <ElectiveCourse> elects = degreeProgram.electiveCourses.ToList();
                foreach (ElectiveCourse elect in elects)
                {
                    FlowchartCourse pcourse = new FlowchartCourse();
                    pcourse.pcourseID = elect.ID;
                    pcourse.elistID   = elect.electiveListID;
                    pcourse.elistName = elect.electiveList.shortName;
                    int order = semesterOrders[elect.semester];
                    pcourse.order = order;
                    semesterOrders[elect.semester] = order + 1;
                    pcourse.semester = elect.semester;
                    pcourse.hours    = elect.credits.ToString();
                    results.Add(pcourse);
                }
                return(Json(results.ToArray(), JsonRequestBehavior.AllowGet));
            }
            return(Json(null));
        }
        public void DegreeProgramsControllerSortByDegreeProgramTitleAsc()
        {
            ViewResult result = controller.Index("title_asc", 1) as ViewResult;

            PagedList.IPagedList <CIS726_Assignment2.Models.DegreeProgram> model = result.Model as PagedList.IPagedList <CIS726_Assignment2.Models.DegreeProgram>;
            DegreeProgram first  = model[0];
            DegreeProgram second = model[1];

            Assert.IsTrue(first.degreeProgramName.CompareTo(second.degreeProgramName) < 0);
        }
        public void DegreeProgramsControllerSortByDegreeProgramTitleDesc()
        {
            ViewResult result = controller.Index("title_desc", 1) as ViewResult;

            PagedList.IPagedList <MessageParser.Models.DegreeProgram> model = result.Model as PagedList.IPagedList <MessageParser.Models.DegreeProgram>;
            DegreeProgram first  = model[0];
            DegreeProgram second = model[1];

            Assert.IsTrue(first.degreeProgramName.CompareTo(second.degreeProgramName) > 0);
        }
        public void DegreeProgramsControllerDeleteFindByID()
        {
            ViewResult    result = controller.Edit(1) as ViewResult;
            DegreeProgram model  = result.Model as DegreeProgram;

            Assert.IsTrue(model.degreeProgramName.Equals("Degree Program 1"));
            result = controller.Edit(2) as ViewResult;
            model  = result.Model as DegreeProgram;
            Assert.IsTrue(model.degreeProgramName.Equals("Degree Program 2"));
        }
 public ActionResult Edit([Bind(Include = "DegreeID,Name,Description")] DegreeProgram degreeProgram)
 {
     if (ModelState.IsValid)
     {
         db.Entry(degreeProgram).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(degreeProgram));
 }
Example #12
0
        DegreeProgram _degreeProgramQueue_Get(DegreeProgram data)
        {
            DegreeProgram degreeProgram = _context.DegreePrograms.Where(i => i.ID == data.ID)
                                          .Include(dp => dp.electiveCourses.Select(s => s.degreeProgram))
                                          .Include(dp => dp.electiveCourses.Select(s => s.electiveList))
                                          .Include(dp => dp.requiredCourses.Select(s => s.course))
                                          .Include(dp => dp.requiredCourses.Select(s => s.degreeProgram))
                                          .First();

            return(degreeProgram);
        }
        public ActionResult Create([Bind(Include = "DegreeID,Name,Description")] DegreeProgram degreeProgram)
        {
            if (ModelState.IsValid)
            {
                db.DegreePrograms.Add(degreeProgram);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(degreeProgram));
        }
Example #14
0
        public ActionResult Create(DegreeProgram degreeprogram)
        {
            if (ModelState.IsValid)
            {
                int anid = Request <DegreeProgram> .Add(degreeprogram, "A", "B");

                return(RedirectToAction("Edit", new { id = anid }));
            }

            return(View(degreeprogram));
        }
Example #15
0
        public ActionResult Delete(int id = 0)
        {
            DegreeProgram degreeprogram = Request <DegreeProgram> .GetItemByID(id, "A", "B");

            if (degreeprogram == null)
            {
                return(HttpNotFound());
            }
            degreeprogram.requiredCourses = degreeprogram.requiredCourses.OrderBy(reqcourse => reqcourse.semester).ThenBy(reqcourse => reqcourse.course.coursePrefix).ThenBy(reqcourse => reqcourse.course.courseNumber).ToList();
            degreeprogram.electiveCourses = degreeprogram.electiveCourses.OrderBy(eleccourse => eleccourse.semester).ThenBy(eleccourse => eleccourse.electiveList.electiveListName).ToList();
            return(View(degreeprogram));
        }
        private DegreeProgram createTempDegreeProgram()
        {
            DegreeProgram temp = new DegreeProgram()
            {
                ID = 3,
                degreeProgramName = "Degree Program 3",
                requiredCourses   = new Collection <RequiredCourse>(),
                electiveCourses   = new Collection <ElectiveCourse>(),
            };

            return(temp);
        }
Example #17
0
        public ActionResult Create(DegreeProgram degreeprogram)
        {
            if (ModelState.IsValid)
            {
                //degreePrograms.Add(degreeprogram);
                //degreePrograms.SaveChanges();
                degreeprogram = _degreeProgramProducer.Create(degreeprogram).First();
                degreeprogram = _degreeProgramProducer.Get(degreeprogram);
                return(RedirectToAction("Edit", new { id = degreeprogram.ID }));
            }

            return(View(degreeprogram));
        }
Example #18
0
        public ActionResult DeleteConfirmed(int id)
        {
            //DegreeProgram degreeprogram = degreePrograms.Find(id);
            DegreeProgram degreeprogram = _degreeProgramProducer.Get(new DegreeProgram()
            {
                ID = id
            });

            //degreePrograms.Remove(degreeprogram);
            //degreePrograms.SaveChanges();
            _degreeProgramProducer.Remove(degreeprogram);
            return(RedirectToAction("Index"));
        }
        // GET: DegreePrograms/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DegreeProgram degreeProgram = db.DegreePrograms.Find(id);

            if (degreeProgram == null)
            {
                return(HttpNotFound());
            }
            return(View(degreeProgram));
        }
Example #20
0
        public ActionResult Delete(int id = 0)
        {
            //DegreeProgram degreeprogram = degreePrograms.Find(id);
            DegreeProgram degreeprogram = _degreeProgramProducer.Get(new DegreeProgram()
            {
                ID = id
            });

            if (degreeprogram == null)
            {
                return(HttpNotFound());
            }
            degreeprogram.requiredCourses = degreeprogram.requiredCourses.OrderBy(reqcourse => reqcourse.semester).ThenBy(reqcourse => reqcourse.course.coursePrefix).ThenBy(reqcourse => reqcourse.course.courseNumber).ToList();
            degreeprogram.electiveCourses = degreeprogram.electiveCourses.OrderBy(eleccourse => eleccourse.semester).ThenBy(eleccourse => eleccourse.electiveList.electiveListName).ToList();
            return(View(degreeprogram));
        }
Example #21
0
        public string whereToGo()
        {
            DegreeProgram degreeProgram = this.CUIProgram;

            if (degreeProgram == DegreeProgram.BSCS || degreeProgram == DegreeProgram.BSSE)
            {
                return("Academic Block-II");
            }
            else if (degreeProgram == DegreeProgram.BBA)
            {
                return("Academic Block-III");
            }
            else if (degreeProgram == DegreeProgram.BTE)
            {
                return("Academic Block-I/EE Block");
            }
            return(null);
        }
        public List <Transcript.StudentCourseReport> GetDegreeReport(string studentIDCheck)
        {
            DegreeProgramDAL programDAL      = new DegreeProgramDAL();
            String           degreeProgram   = programDAL.GetDegreeProgramByStudentID(studentIDCheck);
            CourseCollection requiredCourses = programDAL.GetCoursesByDegreeProgram(degreeProgram);
            DegreeProgram    program         = new DegreeProgram(degreeProgram, requiredCourses);
            StudentDAL       studentDal      = new StudentDAL();
            Student          student         = studentDal.GetStudentByStudentID(studentIDCheck);
            CourseDAL        courseDal       = new CourseDAL();
            List <Course>    coursesTaken    = courseDal.GetCoursesByStudentID(studentIDCheck);
            Transcript       transcript      = new Transcript(program, student, coursesTaken);
            CourseTimeDAL    courseTimeDal   = new CourseTimeDAL();

            foreach (var course in transcript.Courses)
            {
                char?      grade = studentDal.GetGradeByCourseAndStudentID(course.CRN, studentIDCheck);
                CourseTime time  = courseTimeDal.GetCourseTimeByCRN(course.CRN);
                Transcript.StudentCourseReport courseReport = new Transcript.StudentCourseReport(course, program, student, grade, time);
                transcript.CourseReports.Add(courseReport);
            }
            return(transcript.CourseReports);
        }
        protected override void Seed(MessageParser.Models.CourseDBContext context)
        {
            bool seedAll = true;

            if (seedAll)
            {
                string[] semesterTitles = { "January", "Spring", "May", "Summer", "August", "Fall" };

                int semCount = 1;
                for (int i = 2013; i < 2025; i++)
                {
                    for (int k = 0; k < semesterTitles.Length; k++)
                    {
                        if (semesterTitles[k].Equals("Spring") || semesterTitles[k].Equals("Fall"))
                        {
                            context.Semesters.AddOrUpdate(c => c.ID, new Semester()
                            {
                                ID            = semCount++,
                                semesterYear  = i,
                                semesterTitle = semesterTitles[k],
                                standard      = true
                            });
                        }
                        else
                        {
                            context.Semesters.AddOrUpdate(c => c.ID, new Semester()
                            {
                                ID            = semCount++,
                                semesterYear  = i,
                                semesterTitle = semesterTitles[k],
                                standard      = false
                            });
                        }
                    }
                }

                context.SaveChanges();

                String resourceName = "MessageParser.SeedData.";

                XmlTextReader reader   = new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName + "ksu_courses.xml"));
                Course        course   = null;
                String        property = null;
                int           count    = 0;
                Boolean       done     = false;
                while (reader.Read() && !done)
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:     // The node is an element.
                        if (reader.Name.Equals("htmlparse.Course"))
                        {
                            course = new Course();
                        }
                        else
                        {
                            property = reader.Name;
                        }
                        break;

                    case XmlNodeType.Text:     //Display the text in each element.
                        if (property.Equals("id"))
                        {
                            course.ID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("prefix"))
                        {
                            course.coursePrefix = reader.Value;
                        }
                        else if (property.Equals("number"))
                        {
                            course.courseNumber = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("title"))
                        {
                            course.courseTitle = reader.Value;
                        }
                        else if (property.Equals("description"))
                        {
                            course.courseDescription = reader.Value;
                        }
                        else if (property.Equals("minHours"))
                        {
                            course.minHours = int.Parse(reader.Value);
                        }
                        else if (property.Equals("maxHours"))
                        {
                            course.maxHours = int.Parse(reader.Value);
                        }
                        else if (property.Equals("variableHours"))
                        {
                            if (reader.Value.Equals("false"))
                            {
                                course.variable = false;
                            }
                            else
                            {
                                course.variable = true;
                            }
                        }
                        else if (property.Equals("ugrad"))
                        {
                            if (reader.Value.Equals("false"))
                            {
                                course.undergrad = false;
                            }
                            else
                            {
                                course.undergrad = true;
                            }
                        }
                        else if (property.Equals("grad"))
                        {
                            if (reader.Value.Equals("false"))
                            {
                                course.graduate = false;
                            }
                            else
                            {
                                course.graduate = true;
                            }
                        }
                        break;

                    case XmlNodeType.EndElement:     //Display the end of the element.
                        if (reader.Name.Equals("htmlparse.Course"))
                        {
                            try
                            {
                                context.Courses.AddOrUpdate(i => i.ID, course);
                                //if (count++ > 500)
                                //{
                                //    done = true;
                                //}
                            }
                            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                            {
                                var sb = new System.Text.StringBuilder();
                                foreach (var failure in ex.EntityValidationErrors)
                                {
                                    sb.AppendFormat("{0} failed validation", failure.Entry.Entity.GetType());
                                    foreach (var error in failure.ValidationErrors)
                                    {
                                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                                        sb.AppendLine();
                                    }
                                }
                                throw new Exception(sb.ToString());
                            }
                        }
                        break;
                    }
                }
                reader.Close();
                context.SaveChanges();

                reader = new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName + "ksu_electivelists.xml"));
                ElectiveList elist = null;
                property = null;
                count    = 0;
                done     = false;
                while (reader.Read() && !done)
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:     // The node is an element.
                        if (reader.Name.Equals("htmlparse.ElectiveList"))
                        {
                            elist = new ElectiveList();
                        }
                        else
                        {
                            property = reader.Name;
                        }
                        break;

                    case XmlNodeType.Text:     //Display the text in each element.
                        if (property.Equals("id"))
                        {
                            elist.ID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("name"))
                        {
                            elist.electiveListName = reader.Value;
                        }
                        else if (property.Equals("shortname"))
                        {
                            elist.shortName = reader.Value;
                        }
                        break;

                    case XmlNodeType.EndElement:     //Display the end of the element.
                        if (reader.Name.Equals("htmlparse.ElectiveList"))
                        {
                            try
                            {
                                context.ElectiveLists.AddOrUpdate(i => i.ID, elist);
                                //if (count++ > 500)
                                //{
                                //    done = true;
                                //}
                            }
                            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                            {
                                var sb = new System.Text.StringBuilder();
                                foreach (var failure in ex.EntityValidationErrors)
                                {
                                    sb.AppendFormat("{0} failed validation", failure.Entry.Entity.GetType());
                                    foreach (var error in failure.ValidationErrors)
                                    {
                                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                                        sb.AppendLine();
                                    }
                                }
                                throw new Exception(sb.ToString());
                            }
                        }
                        break;
                    }
                }
                reader.Close();
                context.SaveChanges();

                reader = new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName + "ksu_degreeprograms.xml"));
                DegreeProgram dp = null;
                property = null;
                count    = 0;
                done     = false;
                while (reader.Read() && !done)
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:     // The node is an element.
                        if (reader.Name.Equals("htmlparse.DegreeProgram"))
                        {
                            dp = new DegreeProgram();
                        }
                        else
                        {
                            property = reader.Name;
                        }
                        break;

                    case XmlNodeType.Text:     //Display the text in each element.
                        if (property.Equals("id"))
                        {
                            dp.ID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("name"))
                        {
                            dp.degreeProgramName = reader.Value;
                        }
                        else if (property.Equals("description"))
                        {
                            dp.degreeProgramDescription = reader.Value;
                        }
                        break;

                    case XmlNodeType.EndElement:     //Display the end of the element.
                        if (reader.Name.Equals("htmlparse.DegreeProgram"))
                        {
                            try
                            {
                                context.DegreePrograms.AddOrUpdate(i => i.ID, dp);
                                //if (count++ > 500)
                                //{
                                //    done = true;
                                //}
                            }
                            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                            {
                                var sb = new System.Text.StringBuilder();
                                foreach (var failure in ex.EntityValidationErrors)
                                {
                                    sb.AppendFormat("{0} failed validation", failure.Entry.Entity.GetType());
                                    foreach (var error in failure.ValidationErrors)
                                    {
                                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                                        sb.AppendLine();
                                    }
                                }
                                throw new Exception(sb.ToString());
                            }
                        }
                        break;
                    }
                }
                reader.Close();
                context.SaveChanges();

                reader = new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName + "ksu_electivelistcourses.xml"));
                ElectiveListCourse ec = null;
                property = null;
                count    = 0;
                done     = false;
                while (reader.Read() && !done)
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:     // The node is an element.
                        if (reader.Name.Equals("htmlparse.ElectiveListCourse"))
                        {
                            ec = new ElectiveListCourse();
                        }
                        else
                        {
                            property = reader.Name;
                        }
                        break;

                    case XmlNodeType.Text:     //Display the text in each element.
                        if (property.Equals("id"))
                        {
                            ec.ID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("course"))
                        {
                            ec.courseID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("electivelist"))
                        {
                            ec.electiveListID = Int32.Parse(reader.Value);
                        }
                        break;

                    case XmlNodeType.EndElement:     //Display the end of the element.
                        if (reader.Name.Equals("htmlparse.ElectiveListCourse"))
                        {
                            try
                            {
                                context.ElectiveListCourses.AddOrUpdate(i => i.ID, ec);
                                //if (count++ > 500)
                                //{
                                //    done = true;
                                //}
                            }
                            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                            {
                                var sb = new System.Text.StringBuilder();
                                foreach (var failure in ex.EntityValidationErrors)
                                {
                                    sb.AppendFormat("{0} failed validation", failure.Entry.Entity.GetType());
                                    foreach (var error in failure.ValidationErrors)
                                    {
                                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                                        sb.AppendLine();
                                    }
                                }
                                throw new Exception(sb.ToString());
                            }
                        }
                        break;
                    }
                }
                reader.Close();
                context.SaveChanges();

                reader = new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName + "ksu_requiredcourses.xml"));
                RequiredCourse rq = null;
                property = null;
                count    = 0;
                done     = false;
                while (reader.Read() && !done)
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:     // The node is an element.
                        if (reader.Name.Equals("htmlparse.RequiredCourse"))
                        {
                            rq = new RequiredCourse();
                        }
                        else
                        {
                            property = reader.Name;
                        }
                        break;

                    case XmlNodeType.Text:     //Display the text in each element.
                        if (property.Equals("id"))
                        {
                            rq.ID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("course"))
                        {
                            rq.courseID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("degree"))
                        {
                            rq.degreeProgramID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("semester"))
                        {
                            rq.semester = Int32.Parse(reader.Value);
                        }
                        break;

                    case XmlNodeType.EndElement:     //Display the end of the element.
                        if (reader.Name.Equals("htmlparse.RequiredCourse"))
                        {
                            try
                            {
                                context.RequiredCourses.AddOrUpdate(i => i.ID, rq);
                                //if (count++ > 500)
                                //{
                                //    done = true;
                                //}
                            }
                            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                            {
                                var sb = new System.Text.StringBuilder();
                                foreach (var failure in ex.EntityValidationErrors)
                                {
                                    sb.AppendFormat("{0} failed validation", failure.Entry.Entity.GetType());
                                    foreach (var error in failure.ValidationErrors)
                                    {
                                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                                        sb.AppendLine();
                                    }
                                }
                                throw new Exception(sb.ToString());
                            }
                        }
                        break;
                    }
                }
                reader.Close();
                context.SaveChanges();

                reader = new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName + "ksu_electivecourses.xml"));
                ElectiveCourse ecr = null;
                property = null;
                count    = 0;
                done     = false;
                while (reader.Read() && !done)
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:     // The node is an element.
                        if (reader.Name.Equals("htmlparse.ElectiveCourse"))
                        {
                            ecr = new ElectiveCourse();
                        }
                        else
                        {
                            property = reader.Name;
                        }
                        break;

                    case XmlNodeType.Text:     //Display the text in each element.
                        if (property.Equals("id"))
                        {
                            ecr.ID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("degree"))
                        {
                            ecr.degreeProgramID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("electivelist"))
                        {
                            ecr.electiveListID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("semester"))
                        {
                            ecr.semester = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("credits"))
                        {
                            ecr.credits = Int32.Parse(reader.Value);
                        }
                        break;

                    case XmlNodeType.EndElement:     //Display the end of the element.
                        if (reader.Name.Equals("htmlparse.ElectiveCourse"))
                        {
                            try
                            {
                                context.ElectiveCourses.AddOrUpdate(i => i.ID, ecr);
                                //if (count++ > 500)
                                //{
                                //    done = true;
                                //}
                            }
                            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                            {
                                var sb = new System.Text.StringBuilder();
                                foreach (var failure in ex.EntityValidationErrors)
                                {
                                    sb.AppendFormat("{0} failed validation", failure.Entry.Entity.GetType());
                                    foreach (var error in failure.ValidationErrors)
                                    {
                                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                                        sb.AppendLine();
                                    }
                                }
                                throw new Exception(sb.ToString());
                            }
                        }
                        break;
                    }
                }
                reader.Close();
                context.SaveChanges();

                reader = new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName + "ksu_prerequisitecourses.xml"));
                PrerequisiteCourse pre = null;
                property = null;
                count    = 0;
                done     = false;
                while (reader.Read() && !done)
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:     // The node is an element.
                        if (reader.Name.Equals("htmlparse.PrerequisiteCourse"))
                        {
                            pre = new PrerequisiteCourse();
                        }
                        else
                        {
                            property = reader.Name;
                        }
                        break;

                    case XmlNodeType.Text:     //Display the text in each element.
                        if (property.Equals("id"))
                        {
                            pre.ID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("prerequisiteCourse"))
                        {
                            pre.prerequisiteCourseID = Int32.Parse(reader.Value);
                        }
                        else if (property.Equals("prerequisiteFor"))
                        {
                            pre.prerequisiteForCourseID = Int32.Parse(reader.Value);
                        }
                        break;

                    case XmlNodeType.EndElement:     //Display the end of the element.
                        if (reader.Name.Equals("htmlparse.PrerequisiteCourse"))
                        {
                            try
                            {
                                context.PrerequisiteCourses.AddOrUpdate(i => i.ID, pre);
                                //if (count++ > 500)
                                //{
                                //    done = true;
                                //}
                            }
                            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                            {
                                var sb = new System.Text.StringBuilder();
                                foreach (var failure in ex.EntityValidationErrors)
                                {
                                    sb.AppendFormat("{0} failed validation", failure.Entry.Entity.GetType());
                                    foreach (var error in failure.ValidationErrors)
                                    {
                                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                                        sb.AppendLine();
                                    }
                                }
                                throw new Exception(sb.ToString());
                            }
                        }
                        break;
                    }
                }
                reader.Close();
                context.SaveChanges();
            }
        }
Example #24
0
        public ActionResult Edit(DegreeProgram degreeprogram, IEnumerable <RequiredCourse> RequiredCourses, IEnumerable <ElectiveCourse> ElectiveCourses)
        {
            if (ModelState.IsValid)
            {
                //DegreeProgram degreeAttached = degreePrograms.Where(degree => degree.ID == degreeprogram.ID).First();
                DegreeProgram degreeAttached = _degreeProgramProducer.Get(new DegreeProgram()
                {
                    ID = degreeprogram.ID
                });
                degreeprogram.requiredCourses = degreeAttached.requiredCourses;
                degreeprogram.electiveCourses = degreeAttached.electiveCourses;

                if (RequiredCourses == null)
                {
                    RequiredCourses = new List <RequiredCourse>();
                }

                if (ElectiveCourses == null)
                {
                    ElectiveCourses = new List <ElectiveCourse>();
                }

                //figures out which courses were deleted from the form
                LinkedList <RequiredCourse> toRemove = new LinkedList <RequiredCourse>();
                foreach (RequiredCourse course in degreeAttached.requiredCourses)
                {
                    if (course.ID > 0)
                    {
                        if (!RequiredCourses.Contains(course))
                        {
                            //RequiredCourse reqcourseAttached = requiredCourses.Where(reqc => reqc.ID == course.ID).First();
                            RequiredCourse reqcourseAttached = _requiredCourseProducer.Get(new RequiredCourse()
                            {
                                ID = course.ID
                            });
                            toRemove.AddFirst(reqcourseAttached);
                        }
                    }
                }
                //deletes those courses from the list
                while (toRemove.Count > 0)
                {
                    RequiredCourse removeme = toRemove.First();
                    toRemove.RemoveFirst();
                    //requiredCourses.Remove(removeme);
                    _requiredCourseProducer.Remove(removeme);
                }
                //clears the list
                degreeprogram.requiredCourses.Clear();
                //adds the courses that exist to the list
                foreach (RequiredCourse reqcourse in RequiredCourses)
                {
                    RequiredCourse reqcourseAttached = null;;
                    if (reqcourse.ID > 0)
                    {
                        //reqcourseAttached = requiredCourses.Where(reqc => reqc.ID == reqcourse.ID).First();
                        reqcourseAttached = _requiredCourseProducer.Get(new RequiredCourse()
                        {
                            ID = reqcourse.ID
                        });
                        //requiredCourses.UpdateValues(reqcourseAttached, reqcourse);
                        _requiredCourseProducer.Update(reqcourse);
                    }
                    else
                    {
                        //if (courses.Find(reqcourse.courseID) != null)
                        if (_courseProducer.Get(new Course()
                        {
                            ID = reqcourse.courseID
                        }) != null)
                        {
                            //requiredCourses.Add(reqcourse);
                            //requiredCourses.SaveChanges();
                            _requiredCourseProducer.Create(reqcourse);
                            //reqcourseAttached = requiredCourses.Where(reqc => reqc.ID == reqcourse.ID).First();
                            reqcourseAttached = _requiredCourseProducer.Get(new RequiredCourse()
                            {
                                ID = reqcourse.ID
                            });
                        }
                    }
                    if (reqcourseAttached != null)
                    {
                        degreeprogram.requiredCourses.Add(reqcourseAttached);
                    }
                }

                //figures out which elective lists were deleted from the list
                LinkedList <ElectiveCourse> toRemoveMe = new LinkedList <ElectiveCourse>();
                foreach (ElectiveCourse course in degreeAttached.electiveCourses)
                {
                    if (!ElectiveCourses.Contains(course))
                    {
                        //ElectiveCourse elcourseAttached = electiveCourses.Where(elc => elc.ID == course.ID).First();
                        ElectiveCourse elcourseAttached = _electiveCourseProducer.Get(new ElectiveCourse()
                        {
                            ID = course.ID
                        });
                        toRemoveMe.AddFirst(elcourseAttached);
                    }
                }
                //remove those elective lists from the list
                while (toRemoveMe.Count > 0)
                {
                    ElectiveCourse removeme = toRemoveMe.First();
                    toRemoveMe.RemoveFirst();
                    //electiveCourses.Remove(removeme);
                    _electiveCourseProducer.Remove(removeme);
                }
                //clear the list
                degreeprogram.electiveCourses.Clear();
                //add the existing elective lists to the list
                foreach (ElectiveCourse elcourse in ElectiveCourses)
                {
                    ElectiveCourse elcourseAttached = null;;
                    if (elcourse.ID > 0)
                    {
                        //elcourseAttached = electiveCourses.Where(elc => elc.ID == elcourse.ID).First();
                        elcourseAttached = _electiveCourseProducer.Get(new ElectiveCourse()
                        {
                            ID = elcourse.ID
                        });
                        //electiveCourses.UpdateValues(elcourseAttached, elcourse);
                        _electiveCourseProducer.Update(elcourse);
                    }
                    else
                    {
                        //if (electiveLists.Find(elcourse.electiveListID) != null)
                        if (_electiveListProducer.Get(new ElectiveList()
                        {
                            ID = elcourse.electiveListID
                        }) != null)
                        {
                            //electiveCourses.Add(elcourse);
                            //electiveCourses.SaveChanges();
                            _electiveCourseProducer.Create(elcourse);
                            //elcourseAttached = electiveCourses.Where(elc => elc.ID == elcourse.ID).First();
                            elcourseAttached = _electiveCourseProducer.Get(new ElectiveCourse()
                            {
                                ID = elcourse.ID
                            });
                        }
                    }
                    if (elcourseAttached != null)
                    {
                        degreeprogram.electiveCourses.Add(elcourseAttached);
                    }
                }

                //degreePrograms.UpdateValues(degreeAttached, degreeprogram);
                //degreePrograms.SaveChanges();
                _degreeProgramProducer.Update(degreeprogram);
                return(RedirectToAction("Index"));
            }
            if (RequiredCourses != null)
            {
                foreach (RequiredCourse course in RequiredCourses)
                {
                    if (course.courseID > 0)
                    {
                        //course.course = courses.Find(course.courseID);
                        course.course = _courseProducer.Get(new Course()
                        {
                            ID = course.courseID
                        });
                    }
                }
            }
            degreeprogram.requiredCourses = RequiredCourses.ToList();

            if (ElectiveCourses != null)
            {
                foreach (ElectiveCourse course in ElectiveCourses)
                {
                    if (course.electiveListID > 0)
                    {
                        //course.electiveList = electiveLists.Find(course.electiveListID);
                        course.electiveList = _electiveListProducer.Get(new ElectiveList()
                        {
                            ID = course.electiveListID
                        });
                    }
                }
            }
            degreeprogram.electiveCourses = ElectiveCourses.ToList();

            return(View(degreeprogram));
        }
 public void Set(Term Term, CollegeLife Interest, DegreeProgram Program)
 {
     Context.Term     = Term;
     Context.Interest = Interest;
     Context.Program  = Program;
 }
Example #26
0
 DegreeProgram _degreeProgramQueue_Create(DegreeProgram data)
 {
     return(Create(data));
 }
Example #27
0
 void _degreeProgramQueue_Update(DegreeProgram data)
 {
     Update(data);
 }
Example #28
0
        public ActionResult Edit(DegreeProgram degreeprogram, IEnumerable <RequiredCourse> RequiredCourses, IEnumerable <ElectiveCourse> ElectiveCourses)
        {
            if (ModelState.IsValid)
            {
                DegreeProgram degreeAttached = Request <DegreeProgram> .GetItemByID(degreeprogram.ID, "A", "B");

                degreeprogram.requiredCourses = degreeAttached.requiredCourses;
                degreeprogram.electiveCourses = degreeAttached.electiveCourses;

                if (RequiredCourses == null)
                {
                    RequiredCourses = new List <RequiredCourse>();
                }

                if (ElectiveCourses == null)
                {
                    ElectiveCourses = new List <ElectiveCourse>();
                }

                //figures out which courses were deleted from the form
                LinkedList <RequiredCourse> toRemove = new LinkedList <RequiredCourse>();
                foreach (RequiredCourse course in degreeAttached.requiredCourses)
                {
                    if (course.ID > 0)
                    {
                        if (!RequiredCourses.Contains(course))
                        {
                            RequiredCourse reqcourseAttached = Request <RequiredCourse> .GetItemByID(course.ID, "A", "B");

                            toRemove.AddFirst(reqcourseAttached);
                        }
                    }
                }
                //deletes those courses from the list
                while (toRemove.Count > 0)
                {
                    RequiredCourse removeme = toRemove.First();
                    toRemove.RemoveFirst();
                    Request <RequiredCourse> .Delete(removeme.ID, "A", "B");
                }
                //clears the list
                degreeprogram.requiredCourses = new List <RequiredCourse>();
                //adds the courses that exist to the list
                foreach (RequiredCourse reqcourse in RequiredCourses)
                {
                    RequiredCourse reqcourseAttached = null;;
                    if (reqcourse.ID > 0)
                    {
                        reqcourseAttached = Request <RequiredCourse> .GetItemByID(reqcourse.ID, "A", "B");

                        Request <RequiredCourse> .Update(reqcourseAttached, reqcourse, "A", "B");
                    }
                    else
                    {
                        if (Request <Course> .GetItemByID(reqcourse.courseID, "A", "B") != null)
                        {
                            int id = Request <RequiredCourse> .Add(reqcourse, "A", "B");

                            reqcourseAttached = Request <RequiredCourse> .GetItemByID(id, "A", "B");
                        }
                    }
                    if (reqcourseAttached != null)
                    {
                        degreeprogram.requiredCourses.Add(reqcourseAttached);
                    }
                }

                //figures out which elective lists were deleted from the list
                LinkedList <ElectiveCourse> toRemoveMe = new LinkedList <ElectiveCourse>();
                foreach (ElectiveCourse course in degreeAttached.electiveCourses)
                {
                    if (!ElectiveCourses.Contains(course))
                    {
                        ElectiveCourse elcourseAttached = Request <ElectiveCourse> .GetItemByID(course.ID, "A", "B");

                        toRemoveMe.AddFirst(elcourseAttached);
                    }
                }
                //remove those elective lists from the list
                while (toRemoveMe.Count > 0)
                {
                    ElectiveCourse removeme = toRemoveMe.First();
                    toRemoveMe.RemoveFirst();
                    Request <ElectiveCourse> .Delete(removeme.ID, "A", "B");
                }
                //clear the list
                degreeprogram.electiveCourses = new List <ElectiveCourse>();
                //add the existing elective lists to the list
                foreach (ElectiveCourse elcourse in ElectiveCourses)
                {
                    ElectiveCourse elcourseAttached = null;;
                    if (elcourse.ID > 0)
                    {
                        elcourseAttached = Request <ElectiveCourse> .GetItemByID(elcourse.ID, "A", "B");

                        Request <ElectiveCourse> .Update(elcourseAttached, elcourse, "A", "B");
                    }
                    else
                    {
                        if (Request <ElectiveList> .GetItemByID(elcourse.electiveListID, "A", "B") != null)
                        {
                            int id = Request <ElectiveCourse> .Add(elcourse, "A", "B");

                            elcourseAttached = Request <ElectiveCourse> .GetItemByID(id, "A", "B");
                        }
                    }
                    if (elcourseAttached != null)
                    {
                        degreeprogram.electiveCourses.Add(elcourseAttached);
                    }
                }

                Request <DegreeProgram> .Update(degreeAttached, degreeprogram, "A", "B");

                return(RedirectToAction("Index"));
            }
            if (RequiredCourses != null)
            {
                foreach (RequiredCourse course in RequiredCourses)
                {
                    if (course.courseID > 0)
                    {
                        course.course = Request <Course> .GetItemByID(course.courseID, "A", "B");
                    }
                }
            }
            degreeprogram.requiredCourses = RequiredCourses.ToList();

            if (ElectiveCourses != null)
            {
                foreach (ElectiveCourse course in ElectiveCourses)
                {
                    if (course.electiveListID > 0)
                    {
                        course.electiveList = Request <ElectiveList> .GetItemByID(course.electiveListID, "A", "B");
                    }
                }
            }
            degreeprogram.electiveCourses = ElectiveCourses.ToList();

            return(View(degreeprogram));
        }
Example #29
0
 void _degreeProgramQueue_Remove(DegreeProgram data)
 {
     Remove(data);
 }
 public Object Update()
 {
     try
     {
         if (request.Type == ModelType.Course)
         {
             Course value   = (request as Request <Course>).RequestedMembers[0];
             Course replace = (request as Request <Course>).RequestedMembers[1];
             return(new Response <Course>(request as Request <Course>, courses.UpdateAndSave(value, replace)));
         }
         if (request.Type == ModelType.DegreeProgram)
         {
             DegreeProgram value   = (request as Request <DegreeProgram>).RequestedMembers[0];
             DegreeProgram replace = (request as Request <DegreeProgram>).RequestedMembers[1];
             return(new Response <DegreeProgram>(request as Request <DegreeProgram>, degreePrograms.UpdateAndSave(value, replace)));
         }
         if (request.Type == ModelType.ElectiveCourse)
         {
             ElectiveCourse value   = (request as Request <ElectiveCourse>).RequestedMembers[0];
             ElectiveCourse replace = (request as Request <ElectiveCourse>).RequestedMembers[1];
             return(new Response <ElectiveCourse>(request as Request <ElectiveCourse>, electiveCourses.UpdateAndSave(value, replace)));
         }
         if (request.Type == ModelType.ElectiveList)
         {
             ElectiveList value   = (request as Request <ElectiveList>).RequestedMembers[0];
             ElectiveList replace = (request as Request <ElectiveList>).RequestedMembers[1];
             return(new Response <ElectiveList>(request as Request <ElectiveList>, electiveLists.UpdateAndSave(value, replace)));
         }
         if (request.Type == ModelType.ElectiveListCourse)
         {
             ElectiveListCourse value   = (request as Request <ElectiveListCourse>).RequestedMembers[0];
             ElectiveListCourse replace = (request as Request <ElectiveListCourse>).RequestedMembers[1];
             return(new Response <ElectiveListCourse>(request as Request <ElectiveListCourse>, electiveListCourses.UpdateAndSave(value, replace)));
         }
         if (request.Type == ModelType.Plan)
         {
             Plan value   = (request as Request <Plan>).RequestedMembers[0];
             Plan replace = (request as Request <Plan>).RequestedMembers[1];
             return(new Response <Plan>(request as Request <Plan>, plans.UpdateAndSave(value, replace)));
         }
         if (request.Type == ModelType.PlanCourse)
         {
             PlanCourse value   = (request as Request <PlanCourse>).RequestedMembers[0];
             PlanCourse replace = (request as Request <PlanCourse>).RequestedMembers[1];
             return(new Response <PlanCourse>(request as Request <PlanCourse>, planCourses.UpdateAndSave(value, replace)));
         }
         if (request.Type == ModelType.PrerequisiteCourse)
         {
             PrerequisiteCourse value   = (request as Request <PrerequisiteCourse>).RequestedMembers[0];
             PrerequisiteCourse replace = (request as Request <PrerequisiteCourse>).RequestedMembers[1];
             return(new Response <PrerequisiteCourse>(request as Request <PrerequisiteCourse>, prerequisiteCourses.UpdateAndSave(value, replace)));
         }
         if (request.Type == ModelType.RequiredCourse)
         {
             RequiredCourse value   = (request as Request <RequiredCourse>).RequestedMembers[0];
             RequiredCourse replace = (request as Request <RequiredCourse>).RequestedMembers[1];
             return(new Response <RequiredCourse>(request as Request <RequiredCourse>, requiredCourses.UpdateAndSave(value, replace)));
         }
         if (request.Type == ModelType.Semester)
         {
             Semester value   = (request as Request <Semester>).RequestedMembers[0];
             Semester replace = (request as Request <Semester>).RequestedMembers[1];
             return(new Response <Semester>(request as Request <Semester>, semesters.UpdateAndSave(value, replace)));
         }
     }
     catch
     {
         return(null);
     }
     return(null);
 }