コード例 #1
0
        public async Task <IActionResult> Create([Bind("StudentID,Studentname,StudentDoB,StudentAddress")] 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,StartDate,EndDate,CourseDuration")] Course course)
        {
            if (ModelState.IsValid)
            {
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("ID,StudentID,CourseID")] Enrol enrol)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enrol);
                await _context.SaveChangesAsync();

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