Esempio n. 1
0
        PrerequisiteCourse _prerequisiteCourseQueue_Get(PrerequisiteCourse data)
        {
            PrerequisiteCourse prereq = _context.PrerequisiteCourses.Where(i => i.ID == data.ID)
                                        .Include(pc => pc.prerequisiteCourse)
                                        .Include(pc => pc.prerequisiteForCourse)
                                        .First();

            return(prereq);
        }
 /// <summary>
 /// @russfeld
 /// This uses AJAX to return the HTML code for a new course row on the form
 /// Mad props to http://ivanz.com/2011/06/16/editing-variable-length-reorderable-collections-in-asp-net-mvc-part-1/
 /// </summary>
 /// <returns></returns>
 public ActionResult PrerequisiteCourseRow(int id = 0)
 {
     if (id > 0)
     {
         PrerequisiteCourse reqcourse = new PrerequisiteCourse()
         {
             prerequisiteForCourseID = id,
             prerequisiteCourseID    = -1,
         };
         return(PartialView("PrerequisiteCourseFormPartial", reqcourse));
     }
     else
     {
         return(PartialView("PrerequisiteCourseFormPartial"));
     }
 }
        public ActionResult Edit(Course course, IEnumerable <PrerequisiteCourse> PrerequisiteCourses)
        {
            if (ModelState.IsValid)
            {
                Course cAttached = Request <Course> .GetItemByID(course.ID, "A", "B");

                course.prerequisites = cAttached.prerequisites;

                if (PrerequisiteCourses == null)
                {
                    PrerequisiteCourses = new List <PrerequisiteCourse>();
                }

                if (course.prerequisites == null)
                {
                    course.prerequisites = new List <PrerequisiteCourse>();
                }
                //figure out the courses that were removed from the list
                LinkedList <PrerequisiteCourse> toRemove = new LinkedList <PrerequisiteCourse>();
                foreach (PrerequisiteCourse pcourse in course.prerequisites)
                {
                    if (course.ID > 0)
                    {
                        if (!PrerequisiteCourses.Contains(pcourse))
                        {
                            PrerequisiteCourse elcourseAttached = Request <PrerequisiteCourse> .GetItemByID(pcourse.ID, "A", "B");

                            toRemove.AddFirst(elcourseAttached);
                        }
                    }
                }
                //remove those courses from the database
                while (toRemove.Count > 0)
                {
                    PrerequisiteCourse removeme = toRemove.First();
                    toRemove.RemoveFirst();
                    Request <PrerequisiteCourse> .Delete(removeme.ID, "A", "B");
                }
                //clear the list todo
                course.prerequisites = new List <PrerequisiteCourse>();
                //add the existing courses to the database
                foreach (PrerequisiteCourse pcourse in PrerequisiteCourses)
                {
                    PrerequisiteCourse pcourseAttached = null;;
                    if (pcourse.ID > 0)
                    {
                        pcourseAttached = Request <PrerequisiteCourse> .GetItemByID(pcourse.ID, "A", "B");

                        Request <PrerequisiteCourse> .Update(pcourseAttached, pcourse, "A", "B");
                    }
                    else
                    {
                        if (Request <Course> .GetItemByID(pcourse.prerequisiteCourseID, "A", "B") != null)
                        {
                            int id = Request <PrerequisiteCourse> .Add(pcourse, "A", "B");

                            pcourseAttached = Request <PrerequisiteCourse> .GetItemByID(id, "A", "B");
                        }
                    }
                    if (pcourseAttached != null)
                    {
                        course.prerequisites.Add(pcourseAttached);
                    }
                }
                Request <Course> .Update(cAttached, course, "A", "B");

                return(RedirectToAction("Index"));
            }
            if (PrerequisiteCourses != null)
            {
                foreach (PrerequisiteCourse pcourse in PrerequisiteCourses)
                {
                    if (pcourse.prerequisiteCourseID > 0)
                    {
                        pcourse.prerequisiteCourse = Request <Course> .GetItemByID(pcourse.prerequisiteCourseID, "A", "B");
                    }
                }
            }
            course.prerequisites = PrerequisiteCourses.ToList();
            return(View(course));
        }
Esempio n. 4
0
 void _prerequisiteCourseQueue_Update(PrerequisiteCourse data)
 {
     Update(data);
 }
Esempio n. 5
0
 PrerequisiteCourse _prerequisiteCourseQueue_Create(PrerequisiteCourse data)
 {
     return(Create(data));
 }
Esempio n. 6
0
 void _prerequisiteCourseQueue_Remove(PrerequisiteCourse data)
 {
     Remove(data);
 }
Esempio n. 7
0
        public ActionResult Edit(Course course, IEnumerable <PrerequisiteCourse> PrerequisiteCourses)
        {
            var courseList = _courseProducer.GetAll();

            if (ModelState.IsValid)
            {
                Course cAttached = courseList.AsQueryable().Where(c => c.ID == course.ID).First();
                course.prerequisites = cAttached.prerequisites;

                if (PrerequisiteCourses == null)
                {
                    PrerequisiteCourses = new List <PrerequisiteCourse>();
                }

                if (course.prerequisites == null)
                {
                    course.prerequisites = new List <PrerequisiteCourse>();
                }
                //figure out the courses that were removed from the list
                LinkedList <PrerequisiteCourse> toRemove = new LinkedList <PrerequisiteCourse>();
                foreach (PrerequisiteCourse pcourse in course.prerequisites)
                {
                    if (course.ID > 0)
                    {
                        if (!PrerequisiteCourses.Contains(pcourse))
                        {
                            //PrerequisiteCourse elcourseAttached = prerequisiteCourses.Where(reqc => reqc.ID == pcourse.ID).First();
                            PrerequisiteCourse elcourseAttached = _prerequisiteCourseProducer.Get(new PrerequisiteCourse()
                            {
                                ID = pcourse.ID
                            });
                            toRemove.AddFirst(elcourseAttached);
                        }
                    }
                }
                //remove those courses from the database
                while (toRemove.Count > 0)
                {
                    PrerequisiteCourse removeme = toRemove.First();
                    toRemove.RemoveFirst();
                    //prerequisiteCourses.Remove(removeme);
                    _prerequisiteCourseProducer.Remove(removeme);
                }
                //clear the list
                course.prerequisites.Clear();
                //add the existing courses to the database
                foreach (PrerequisiteCourse pcourse in PrerequisiteCourses)
                {
                    PrerequisiteCourse pcourseAttached = null;;
                    if (pcourse.ID > 0)
                    {
                        //pcourseAttached = prerequisiteCourses.Where(reqc => reqc.ID == pcourse.ID).First();
                        pcourseAttached = _prerequisiteCourseProducer.Get(new PrerequisiteCourse()
                        {
                            ID = pcourse.ID
                        });
                        //prerequisiteCourses.UpdateValues(pcourseAttached, pcourse);
                        _prerequisiteCourseProducer.Update(pcourse); //TODO: check if works correctly or need to switch w/ pcourseAttached
                    }
                    else
                    {
                        if (courseList.FirstOrDefault(x => x.ID == pcourse.prerequisiteCourseID) != null)
                        {
                            //prerequisiteCourses.Add(pcourse);
                            //prerequisiteCourses.SaveChanges();
                            _prerequisiteCourseProducer.Create(pcourse);

                            //pcourseAttached = prerequisiteCourses.Where(reqc => reqc.ID == pcourse.ID).First();
                            pcourseAttached = _prerequisiteCourseProducer.Get(new PrerequisiteCourse()
                            {
                                ID = pcourse.ID
                            });
                        }
                    }
                    if (pcourseAttached != null)
                    {
                        course.prerequisites.Add(pcourseAttached);
                    }
                }
                //courses.UpdateValues(cAttached, course);
                //courses.SaveChanges();
                return(RedirectToAction("Index"));
            }
            if (PrerequisiteCourses != null)
            {
                foreach (PrerequisiteCourse pcourse in PrerequisiteCourses)
                {
                    if (pcourse.prerequisiteCourseID > 0)
                    {
                        //pcourse.prerequisiteCourse = courses.Find(pcourse.prerequisiteCourseID);
                        pcourse.prerequisiteCourse = courseList.FirstOrDefault(x => x.ID == pcourse.prerequisiteCourseID);
                    }
                }
            }
            course.prerequisites = PrerequisiteCourses.ToList();
            return(View(course));
        }
        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();
            }
        }
 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);
 }
 public Object Add()
 {
     try
     {
         if (request.Type == ModelType.Course)
         {
             Course value = (request as Request <Course>).RequestedMembers.First();
             return(new Response <Course>(request as Request <Course>, courses.AddAndSave(value)));
         }
         if (request.Type == ModelType.DegreeProgram)
         {
             DegreeProgram value = (request as Request <DegreeProgram>).RequestedMembers.First();
             return(new Response <DegreeProgram>(request as Request <DegreeProgram>, degreePrograms.AddAndSave(value)));
         }
         if (request.Type == ModelType.ElectiveCourse)
         {
             ElectiveCourse value = (request as Request <ElectiveCourse>).RequestedMembers.First();
             return(new Response <ElectiveCourse>(request as Request <ElectiveCourse>, electiveCourses.AddAndSave(value)));
         }
         if (request.Type == ModelType.ElectiveList)
         {
             ElectiveList value = (request as Request <ElectiveList>).RequestedMembers.First();
             return(new Response <ElectiveList>(request as Request <ElectiveList>, electiveLists.AddAndSave(value)));
         }
         if (request.Type == ModelType.ElectiveListCourse)
         {
             ElectiveListCourse value = (request as Request <ElectiveListCourse>).RequestedMembers.First();
             return(new Response <ElectiveListCourse>(request as Request <ElectiveListCourse>, electiveListCourses.AddAndSave(value)));
         }
         if (request.Type == ModelType.Plan)
         {
             Plan value = (request as Request <Plan>).RequestedMembers.First();
             return(new Response <Plan>(request as Request <Plan>, plans.AddAndSave(value)));
         }
         if (request.Type == ModelType.PlanCourse)
         {
             PlanCourse value = (request as Request <PlanCourse>).RequestedMembers.First();
             return(new Response <PlanCourse>(request as Request <PlanCourse>, planCourses.AddAndSave(value)));
         }
         if (request.Type == ModelType.PrerequisiteCourse)
         {
             PrerequisiteCourse value = (request as Request <PrerequisiteCourse>).RequestedMembers.First();
             return(new Response <PrerequisiteCourse>(request as Request <PrerequisiteCourse>, prerequisiteCourses.AddAndSave(value)));
         }
         if (request.Type == ModelType.RequiredCourse)
         {
             RequiredCourse value = (request as Request <RequiredCourse>).RequestedMembers.First();
             return(new Response <RequiredCourse>(request as Request <RequiredCourse>, requiredCourses.AddAndSave(value)));
         }
         if (request.Type == ModelType.Semester)
         {
             Semester value = (request as Request <Semester>).RequestedMembers.First();
             return(new Response <Semester>(request as Request <Semester>, semesters.AddAndSave(value)));
         }
     }
     catch
     {
         return(null);
     }
     return(null);
 }