Exemple #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Enrollment_174852 enrollment_174852 = db.Enrollment_174852.Find(id);

            db.Enrollment_174852.Remove(enrollment_174852);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #2
0
 public ActionResult Edit([Bind(Include = "CourseId,StudentId")] Enrollment_174852 enrollment_174852)
 {
     if (ModelState.IsValid)
     {
         db.Entry(enrollment_174852).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CourseId  = new SelectList(db.Courses_174852, "CourseId", "CourseName", enrollment_174852.CourseId);
     ViewBag.StudentId = new SelectList(db.Student_174852, "StudentId", "Username", enrollment_174852.StudentId);
     return(View(enrollment_174852));
 }
Exemple #3
0
        // GET: Enrollment_174852/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Enrollment_174852 enrollment_174852 = db.Enrollment_174852.Find(id);

            if (enrollment_174852 == null)
            {
                return(HttpNotFound());
            }
            return(View(enrollment_174852));
        }
Exemple #4
0
        // GET: Enrollment_174852/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Enrollment_174852 enrollment_174852 = db.Enrollment_174852.Find(id);

            if (enrollment_174852 == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CourseId  = new SelectList(db.Courses_174852, "CourseId", "CourseName", enrollment_174852.CourseId);
            ViewBag.StudentId = new SelectList(db.Student_174852, "StudentId", "Username", enrollment_174852.StudentId);
            return(View(enrollment_174852));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "CourseId,StudentId")] Enrollment_174852 enrollment_174852)
        {
            if (ModelState.IsValid)
            {
                var res = db.Enrollment_174852.Where(a => a.StudentId == enrollment_174852.StudentId).FirstOrDefault();
                if (res == null)
                {
                    db.Enrollment_174852.Add(enrollment_174852);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Student"));
                }
                else
                {
                    ModelState.AddModelError("", "May be You are Already Enrolled with One Course ");
                }
            }

            ViewBag.CourseId  = new SelectList(db.Courses_174852, "CourseId", "CourseName", enrollment_174852.CourseId);
            ViewBag.StudentId = new SelectList(db.Student_174852, "StudentId", "Username", enrollment_174852.StudentId);
            return(View(enrollment_174852));
        }