public ActionResult DeleteConfirmed(int id)
        {
            TrainingCourseTimetable trainingCourseTimetable = db.TrainingCourseTimetables.Find(id);
            int courseId = trainingCourseTimetable.TrainingCourseId;

            db.TrainingCourseTimetables.Remove(trainingCourseTimetable);
            db.SaveChanges();
            return(RedirectToAction("FindByCourseId", new { id = courseId }));
        }
 public ActionResult Edit([Bind(Include = "CourseStartTime,CourseEndTime,TrainingCourseId,IsLastOne")] TrainingCourseTimetable trainingCourseTimetable)
 {
     if (ModelState.IsValid)
     {
         db.Entry(trainingCourseTimetable).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TrainingCourseId = new SelectList(db.TrainingCourses, "Id", "CourseName", trainingCourseTimetable.TrainingCourseId);
     return(View(trainingCourseTimetable));
 }
        // GET: TrainingCourseTimetables/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TrainingCourseTimetable trainingCourseTimetable = db.TrainingCourseTimetables.Find(id);

            if (trainingCourseTimetable == null)
            {
                return(HttpNotFound());
            }
            return(View(trainingCourseTimetable));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TrainingCourseTimetable trainingCourseTimetable = db.TrainingCourseTimetables.Find(id);

            if (trainingCourseTimetable == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TrainingCourseId = new SelectList(db.TrainingCourses, "Id", "CourseName", trainingCourseTimetable.TrainingCourseId);
            return(View(trainingCourseTimetable));
        }
 public ActionResult Create([Bind(Include = "CourseStartTime,CourseEndTime,TrainingCourseId,IsLastOne")] int courseId, TimetableViewModel.AddTimetableModel newTimetable)
 {
     if (ModelState.IsValid && CheckTimeCollision(courseId, newTimetable))
     {
         TrainingCourseTimetable trainingCourseTimetable = new TrainingCourseTimetable();
         trainingCourseTimetable.CourseStartTime  = newTimetable.CourseStartTime;
         trainingCourseTimetable.CourseEndTime    = newTimetable.CourseEndTime;
         trainingCourseTimetable.TrainingCourseId = courseId;
         trainingCourseTimetable.IsLastOne        = newTimetable.IsLastOne;
         db.TrainingCourseTimetables.Add(trainingCourseTimetable);
         db.SaveChanges();
         return(RedirectToAction("FindByCourseId", new { id = courseId }));
     }
     ViewBag.courseId = courseId;
     return(View(newTimetable));
 }