예제 #1
0
        public ActionResult AddCourseVM(AddCourseViewModel vModel)
        {
            Student stu = db.Students.Find(vModel.Student.ID);

            foreach (Course c in vModel.PossibleCourses)
            {
                if (c.Selected)
                {
                    BaseCourse bc = db.BaseCourses.Find(c.BaseCourse.ID);
                    c.BaseCourse      = bc;
                    ViewData["grade"] = new SelectList(vModel.PossibleCourses);
                    stu.CoursesTaken.Add(c);

                    db.Entry(c).State = EntityState.Added;
                }
            }

            if (stu != null)
            {
                db.Entry(stu).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("ListTakenCourses", new { id = stu.ID }));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            BaseCourse baseCourse = db.BaseCourses.Find(id);

            db.BaseCourses.Remove(baseCourse);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        private static BaseCourse PrereqsMapCourse(IDataReader reader)
        {
            BaseCourse item          = new BaseCourse();
            int        startingIndex = 0;

            item.Id         = reader.GetSafeInt32(startingIndex++);
            item.CourseName = reader.GetSafeString(startingIndex++);

            return(item);
        }
        public ActionResult ResetPreReqs(int?id)
        {
            BaseCourse bc = db.BaseCourses.Find(id);

            db.Prerequisites.RemoveRange(bc.Prerequisites);
            bc.Prerequisites.Clear();
            db.Entry(bc).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Details", new { id = bc.ID }));
        }
 public ActionResult Edit([Bind(Include = "ID,Name,Department,CourseNumber,CreditHours")] BaseCourse baseCourse)
 {
     if (ModelState.IsValid)
     {
         db.Entry(baseCourse).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(baseCourse));
 }
        public ActionResult Create([Bind(Include = "ID,Name,Department,CourseNumber,CreditHours")] BaseCourse baseCourse)
        {
            if (ModelState.IsValid)
            {
                db.BaseCourses.Add(baseCourse);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(baseCourse));
        }
        public ActionResult AddPreReq(int?id, string preReqName)
        {
            BaseCourse   bc     = db.BaseCourses.Find(id);
            Prerequisite prereq = new Prerequisite();

            prereq.BaseCourse_PreReqIsFor = bc;
            prereq.PrereqName             = preReqName;
            db.Prerequisites.Add(prereq);
            bc.Prerequisites.Add(prereq);
            db.Entry(bc).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Details", new { id = bc.ID }));
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BaseCourse baseCourse = db.BaseCourses.Find(id);

            if (baseCourse == null)
            {
                return(HttpNotFound());
            }
            return(View(baseCourse));
        }
예제 #9
0
        public Course Get(int id)
        {
            Course course = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Courses_SelectByIdV2",
                                    inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Id", id);
            }, map : delegate(IDataReader reader, short set)
            {
                if (set == 0)
                {
                    course = MapCourse(reader);
                }
                else if (set == 1)
                {
                    CourseTag ct = TagMapCourse(reader);
                    if (course.Tags == null)
                    {
                        course.Tags = new List <CourseTag>();
                    }
                    course.Tags.Add(ct);
                }

                else if (set == 2)
                {
                    CourseInstructors imc = InstructorsMapCourse(reader);
                    if (course.Instructors == null)
                    {
                        course.Instructors = new List <CourseInstructors>();
                    }
                    course.Instructors.Add(imc);
                }

                else if (set == 3)
                {
                    BaseCourse bc = PrereqsMapCourse(reader);
                    if (course.Prereqs == null)
                    {
                        course.Prereqs = new List <BaseCourse>();
                    }
                    course.Prereqs.Add(bc);
                }
            });
            return(course);
        }
예제 #10
0
        private static BaseCourse PrereqsMapCourse(IDataReader reader)
        {
            BaseCourse item = new BaseCourse();
            int startingIndex = 0;
            item.Id = reader.GetSafeInt32(startingIndex++);
            item.CourseName = reader.GetSafeString(startingIndex++);

            return item;
        }
예제 #11
0
        public Track Get(int id)
        {
            Track item = null;

            TrackCourse getTrackCourse = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Tracks_SelectById"
               , inputParamMapper: delegate(SqlParameterCollection paramCollection)
               {
                   paramCollection.AddWithValue("@Id", id);
                   //model binding
               }, map: delegate(IDataReader reader, short set)
               {
                   if (set == 0)
                   {
                       item = new Track();
                       int startingIndex = 0; //startingOrdinal

                       item.Id = reader.GetSafeInt32(startingIndex++);
                       item.Name = reader.GetSafeString(startingIndex++);
                       item.Format = reader.GetSafeInt32(startingIndex++);
                       item.ExpectedOutcome = reader.GetSafeString(startingIndex++);
                       item.Cost = reader.GetSafeInt32(startingIndex++);
                       item.Description = reader.GetSafeString(startingIndex++);
                   }
                   else if (set == 1 && item != null)
                   {
                       getTrackCourse = new TrackCourse();
                       int startingIndex = 0;

                       getTrackCourse.CourseId = reader.GetSafeInt32(startingIndex++);
                       getTrackCourse.Order = reader.GetSafeInt32(startingIndex++);
                       getTrackCourse.CourseName = reader.GetSafeString(startingIndex);

                       if (item.TracksCourses == null)
                       {
                           item.TracksCourses = new List<TrackCourse>();
                       }

                       if( item.CourseIds == null)
                       {
                           item.CourseIds = new List<int>();
                       }

                       item.TracksCourses.Add(getTrackCourse);
                       item.CourseIds.Add(getTrackCourse.CourseId);

                   }

                   else if (set == 2 && item != null)
                   {
                       BaseCourse prereq = new BaseCourse();
                       int startingIndex = 0;

                       prereq.CourseName = reader.GetSafeString(startingIndex++);
                       prereq.Id = reader.GetSafeInt32(startingIndex);

                       if (item.Prerequisites == null)
                       {
                           item.Prerequisites = new List<BaseCourse>();
                       }

                       item.Prerequisites.Add(prereq);

                   }

               });

            return item;
        }
예제 #12
0
        public List<Track> GetTrackList()
        {
            List<Track> list = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.Tracks_SelectAll"
               , inputParamMapper: null
               , map: delegate(IDataReader reader, short set)
               {
                   if (set == 0)
                   {
                       Track ct = new Track();
                       int startingIndex = 0;

                       ct.Id = reader.GetSafeInt32(startingIndex++);
                       ct.Name = reader.GetSafeString(startingIndex++);
                       ct.Format = reader.GetSafeInt32(startingIndex++);
                       ct.ExpectedOutcome = reader.GetSafeString(startingIndex++);
                       ct.Cost = reader.GetSafeInt32(startingIndex++);
                       ct.Description = reader.GetSafeString(startingIndex++);

                       if (list == null)
                       {
                           list = new List<Track>();
                       }

                       list.Add(ct);
                   }
                   else if (set == 1 && list != null)
                   {
                       TrackCourse item = new TrackCourse();
                       int startingIndex = 0;

                       var TracksId = reader.GetSafeInt32(startingIndex++);
                       item.CourseId = reader.GetSafeInt32(startingIndex++);
                       item.Order = reader.GetSafeInt32(startingIndex++);
                       item.CourseName = reader.GetSafeString(startingIndex++);
                       foreach (var track in list)
                       {
                           if (track.Id == TracksId)
                           {
                               if (track.TracksCourses == null)
                               {
                                   track.TracksCourses = new List<TrackCourse>();
                               }

                               track.TracksCourses.Add(item);
                           }
                       }
                   }

                   else if (set == 2 && list != null)
                   {
                       BaseCourse prereq = new BaseCourse();
                       int startingIndex = 0;

                       prereq.TracksId = reader.GetSafeInt32(startingIndex++);
                       prereq.CourseName = reader.GetSafeString(startingIndex++);
                       prereq.Id = reader.GetSafeInt32(startingIndex);

                       foreach (var track in list)
                       {
                           if (track.Id == prereq.TracksId)
                           {
                               if (track.Prerequisites == null)
                               {
                                   track.Prerequisites = new List<BaseCourse>();
                               }
                               track.Prerequisites.Add(prereq);
                           }
                       }
                   }
               });

            return list;
        }
예제 #13
0
        public ActionResult AddPreReq(int?id)
        {
            BaseCourse baseCourse = db.BaseCourses.Find(id);

            return(View("AddPreReq", baseCourse));
        }