Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("StudentId,Name,Address,Nationality,CourseId")] Students students)
        {
            if (id != students.StudentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(students);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentsExists(students.StudentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"] = new SelectList(_context.Courses, "CourseId", "CourseId", students.CourseId);
            return(View(students));
        }
        public async Task <IActionResult> Edit(int id, [Bind("CourseId,Name,DelieveryMode,Coordinator,Fees")] Courses courses)
        {
            if (id != courses.CourseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(courses);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CoursesExists(courses.CourseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(courses));
        }