示例#1
0
        public async Task <IActionResult> Create([Bind("StudentId,FirstName,LastName")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("CourseID,CourseName,CourseNumber")] Course course)
        {
            if (ModelState.IsValid)
            {
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
        public async Task <IActionResult> Create([Bind("EnrollmentId,StudentId,CourseId")] Enrollments enrollments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enrollments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(_context.Course, "CourseID", "CourseID", enrollments.CourseId);
            ViewData["StudentId"] = new SelectList(_context.Student, "StudentId", "StudentId", enrollments.StudentId);
            return(View(enrollments));
        }