示例#1
0
        public IActionResult Edit(LessonViewModel vm)
        {
            var lessonToEdit = _traversalService.GetLesson(vm.Id);

            if (lessonToEdit == null)
            {
                return(RedirectToAction("ResourceNotFound", "Error", new { error = "przedmiot o takim Id nie istnieje." }));
            }

            lessonToEdit.Update(vm.TitleOrFullName, vm.SubtitleOrAbbreviation);

            bool success = _managementService.UpdateLesson(lessonToEdit);

            if (!success)
            {
                ModelState.AddModelError("ERROR", "Przedmiot o takiej nazwie lub skrócie istnieje już na tym wydziale w tym semestrze");
                return(View(vm));
            }

            return(RedirectToAction("Lessons", new { semesterId = vm.SemesterId, departmentId = vm.DepartmentId }));
        }
示例#2
0
 public void Update(Lesson lesson)
 {
     _managementService.UpdateLesson(lesson);
 }