Esempio n. 1
0
        public IActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var teacher = teacherService.FindTeacher((int)id);

            if (teacher == null)
            {
                return(NotFound());
            }
            return(View(teacher));
        }
        public IActionResult Edit(EditCourseVM course)
        {
            if (ModelState.IsValid)
            {
                var teacherF = TeacherRepo.FindTeacher(course.TeacherId);

                var courseToUpdate = new Course
                {
                    Name        = course.Name,
                    Description = course.Description,
                    Teacher     = teacherF,
                    Id          = course.CourseId
                };
                CourseRepo.UpdateCourse(courseToUpdate);
                return(RedirectToAction(nameof(Index)));
            }

            course.Teachers = TeacherRepo.GetAll();
            return(View(course));
        }