public ActionResult Index(string YourDropDown)
        {
            var studentID = User.Identity.GetUserName();
            Student_Enrollment_Entities student_EnrollmentEntities = new Student_Enrollment_Entities();

            if (student_EnrollmentEntities.Students.Find(studentID) == null)
            {
                var newStudent = new Student {
                    Student_email = studentID
                };
                student_EnrollmentEntities.Students.Add(newStudent);
                student_EnrollmentEntities.SaveChanges();
            }

            string selected = Request.Form["YourDropDown"];

            if (selected == "COEN")
            {
                Sequential COEN = student_EnrollmentEntities.Sequentials.FirstOrDefault(x => x.SequentialID == 100);
                student_EnrollmentEntities.Students.FirstOrDefault(x => x.Student_email == studentID).Sequentials.Add(COEN);
            }
            else if (selected == "ELEN")
            {
                Sequential ELEN = student_EnrollmentEntities.Sequentials.FirstOrDefault(x => x.SequentialID == 101);
                student_EnrollmentEntities.Students.FirstOrDefault(x => x.Student_email == studentID).Sequentials.Add(ELEN);
            }
            student_EnrollmentEntities.SaveChanges();
            return(View());
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "Student_email")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
        public ActionResult Create([Bind(Include = "Course_ID,Course_name,Credits,Requisites,Requisite")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.Courses.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(course));
        }
        public ActionResult Create([Bind(Include = "Term_ID,Course_ID,Student_email,Grade1")] Grade grade)
        {
            if (ModelState.IsValid)
            {
                db.Grades.Add(grade);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Course_ID     = new SelectList(db.Courses, "Course_ID", "Course_ID", grade.Course_ID);
            ViewBag.Student_email = new SelectList(db.Students, "Student_email", "Student_email", grade.Student_email);
            ViewBag.Term_ID       = new SelectList(db.Terms, "Term_ID", "Term_ID", grade.Term_ID);
            return(View(grade));
        }