public ActionResult Create([Bind(Include = "CourseId,Title,Description,Credits,InstructorName")] Course course) { if (ModelState.IsValid) { db.Courses.Add(course); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(course)); }
public ActionResult Create([Bind(Include = "StudentId,LastName,FirstName, Notes, Address1, Address2, City, Zipcode, State")] Student student) { if (ModelState.IsValid) { db.Students.Add(student); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult OnPost() { if (!ModelState.IsValid) { Students = _enrollmentdbcontext.Students.ToList(); return(Page()); } _enrollmentdbcontext.Students.Add(Student); _enrollmentdbcontext.SaveChanges(); return(Redirect("/student")); }
public ActionResult Create([Bind(Include = "StudentID,StudentLastName,StudentFirstName,Address1,Address2,City,Zipcode,State")] Student student) { if (ModelState.IsValid) { EnrollmentDBContext.Students.Add(student); EnrollmentDBContext.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Create([Bind(Include = "EnrollmentID,StudentID,CourseID,Grade,IsActive,AssignedCampus,EnrollmentSemester,EnrollmentYear,Notes")] Enrollment enrollment) { if (ModelState.IsValid) { db.Enrollments.Add(enrollment); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Title", enrollment.CourseID); ViewBag.StudentID = new SelectList(db.Students, "StudentID", "LastName", enrollment.StudentID); return(View(enrollment)); }
public ActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } Student stud = new Student(); stud = _enrollmentdbcontext.Students.FirstOrDefault(student => student.StudentId == Student.StudentId); if (stud != null) { stud.Name = Student.Name; stud.Age = Student.Age; stud.Address = Student.Address; _enrollmentdbcontext.Update(stud); _enrollmentdbcontext.SaveChanges(); } return(Redirect("Student")); }