예제 #1
0
        public ActionResult Create(Course course)
        {
            if (ModelState.IsValid)
            {
                db.Courses.AddObject(course);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.TeacherID = new SelectList(db.Teachers, "TeacherID", "First_Name", course.TeacherID);
            return View(course);
        }
예제 #2
0
 public ActionResult Edit(Course course)
 {
     if (ModelState.IsValid)
     {
         db.Courses.Attach(course);
         db.ObjectStateManager.ChangeObjectState(course, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.TeacherID = new SelectList(db.Teachers, "TeacherID", "First_Name", course.TeacherID);
     return View(course);
 }
예제 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Courses EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCourses(Course course)
 {
     base.AddObject("Courses", course);
 }
예제 #4
0
 /// <summary>
 /// Create a new Course object.
 /// </summary>
 /// <param name="courseID">Initial value of the CourseID property.</param>
 /// <param name="course_Number">Initial value of the Course_Number property.</param>
 /// <param name="subject">Initial value of the Subject property.</param>
 /// <param name="meeting_Time">Initial value of the Meeting_Time property.</param>
 /// <param name="location">Initial value of the Location property.</param>
 public static Course CreateCourse(global::System.Int32 courseID, global::System.String course_Number, global::System.String subject, global::System.String meeting_Time, global::System.String location)
 {
     Course course = new Course();
     course.CourseID = courseID;
     course.Course_Number = course_Number;
     course.Subject = subject;
     course.Meeting_Time = meeting_Time;
     course.Location = location;
     return course;
 }