public async Task <IActionResult> Create([Bind("Id,Name,Email")] Student student) { if (ModelState.IsValid) { _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(student)); }
public async Task <IActionResult> Create([Bind("Id,CourseName,Description,Duration,Price")] Course course) { if (ModelState.IsValid) { _context.Add(course); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(course)); }
public async Task <IActionResult> Create([Bind("Id,CourseId,InstructorId,StudentId")] Enrollment enrollment) { if (ModelState.IsValid) { _context.Add(enrollment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.Course, "Id", "Id", enrollment.CourseId); ViewData["InstructorId"] = new SelectList(_context.Set <Instructor>(), "Id", "Id", enrollment.InstructorId); ViewData["StudentId"] = new SelectList(_context.Set <Student>(), "Id", "Id", enrollment.StudentId); return(View(enrollment)); }