Exemple #1
0
        public IActionResult Add(DepartmentViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            var university = _traversalService.GetUniversity(vm.UniversityId);

            if (university == null)
            {
                return(RedirectToAction("ResourceNotFound", "Error", new { error = "uczelnia o podanym Id nie istnieje." }));
            }

            var departmentToAdd = new BLL.Models.Department(vm.TitleOrFullName, vm.SubtitleOrAbbreviation, university);

            var success = _managementService.AddDepartment(departmentToAdd);

            if (!success)
            {
                ModelState.AddModelError("ERROR", "Wydział o takiej nazwie lub skrócie istnieje już na tej uczelni");
                return(View(vm));
            }

            return(RedirectToAction("Departments", new { universityId = vm.UniversityId }));
        }
 public void Post(Department department)
 {
     _managementService.AddDepartment(department);
 }