public async Task <IActionResult> Edit(int id, [Bind("CourseID,CourseName,StartDate,EndDate,CourseDuration")] Course course)
        {
            if (id != course.CourseID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.CourseID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
        public async Task <IActionResult> Edit(int id, [Bind("StudentID,StudentFname,StudentLname,StudentDoB,StudentAddress")] Student student)
        {
            if (id != student.StudentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.StudentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,StudentID,CourseID")] Enrol enrol)
        {
            if (id != enrol.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrol);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrolExists(enrol.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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));
        }