// GET: EnrollInACourses/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EnrollInACourse enrollInACourse = db.EnrollInACourses.Find(id);

            if (enrollInACourse == null)
            {
                return(HttpNotFound());
            }
            return(View(enrollInACourse));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            EnrollInACourse enrollInACourse = db.EnrollInACourses.Find(id);

            db.EnrollInACourses.Remove(enrollInACourse);
            try
            {
                db.SaveChanges();
            }
            catch (Exception exception)
            {
                return(View("ErrorPage"));
            }
            return(RedirectToAction("Index"));
        }
        // GET: EnrollInACourses/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EnrollInACourse enrollInACourse = db.EnrollInACourses.Find(id);

            if (enrollInACourse == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CourseId  = new SelectList(db.Courses, "CourseId", "Name", enrollInACourse.CourseId);
            ViewBag.StudentId = new SelectList(db.Students, "StudentId", "Name", enrollInACourse.StudentId);
            return(View(enrollInACourse));
        }
 public ActionResult Edit([Bind(Include = "EnrollInACourseId,Date,CourseId,StudentId")] EnrollInACourse enrollInACourse)
 {
     if (ModelState.IsValid)
     {
         db.Entry(enrollInACourse).State = EntityState.Modified;
         try
         {
             db.SaveChanges();
         }
         catch (Exception exception)
         {
             return(View("ErrorPage"));
         }
         return(RedirectToAction("Index"));
     }
     ViewBag.CourseId  = new SelectList(db.Courses, "CourseId", "Name", enrollInACourse.CourseId);
     ViewBag.StudentId = new SelectList(db.Students, "StudentId", "Name", enrollInACourse.StudentId);
     return(View(enrollInACourse));
 }