public async Task <IActionResult> Create([Bind("CourseID,CourseNumber,CourseName,CourseDescription")] Courses courses) { if (ModelState.IsValid) { _context.Add(courses); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(courses)); }
public async Task <IActionResult> Create([Bind("StudentID,FirstName,LastName,EmailAddress,PhoneNumber")] Students students) { if (ModelState.IsValid) { _context.Add(students); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(students)); }
public async Task <IActionResult> Create([Bind("InstructorId,FirstName,LastName,EmailAddress")] Instructors instructor, Courses course) { if (ModelState.IsValid) { if (course != null) { var newCourse = _context.Courses.Where(c => c.CourseID == course.CourseID).SingleOrDefault(); instructor.InstructorId = _context.Instructors.AsEnumerable().Last().InstructorId + 1; instructor.Courses = newCourse; _context.Add(instructor); await _context.SaveChangesAsync(); // return RedirectToAction(nameof(Index)); } } return(RedirectToAction("Index")); }