예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,Age")] Student student)
        {
            if (id != student.ID)
            {
                return(NotFound());
            }

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

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrollments);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrollmentsExists(enrollments.StudentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseID"]  = new SelectList(_context.Courses, "ID", "ID", enrollments.CourseID);
            ViewData["StudentID"] = new SelectList(_context.Students, "ID", "ID", enrollments.StudentID);
            return(View(enrollments));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,CourseCode,Technology,Price")] Course course)
        {
            if (id != course.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
예제 #4
0
 public IActionResult Update(Enrollment r)
 {
     _context.Update(r);
     _context.SaveChanges();
     return(RedirectToAction("Details"));
 }