Esempio n. 1
0
        public ActionResult FacultyEdit(EditFaculty editFaculty, string[] names, string[] namesExam)
        {
            if (!ModelState.IsValid)
            {
                return(View(editFaculty));
            }

            var faculty = _facultyService.Get(editFaculty.Id);

            _mapper.Map(editFaculty, faculty);

            if (names != null)
            {
                faculty.FacultySubjects.Clear();
                _facultyService.GetFacultyWithFacultySubjects(faculty, names);
            }
            else
            {
                faculty.FacultySubjects = _facultyService.GetFacultySubjects(faculty.Id).ToList();
            }

            if (namesExam != null)
            {
                faculty.ExaminationSubjects.Clear();
                _facultyService.GetFacultyWithExamSubjects(faculty, namesExam);
            }
            else
            {
                faculty.ExaminationSubjects = _facultyService.GetExamSubjects(faculty.Id).ToList();
            }

            _facultyService.Update(faculty);

            return(RedirectToAction("GetFaculty", "Faculty", new { area = "Operator" }));
        }