public IActionResult Delete(int?id) { if (id == null) { return(NotFound()); } var department = _departmantService.GetById((int)id); var departmentCount = _personalService.GetAllByDepartmentId((int)id).Count; if (department == null) { return(NotFound()); } if (departmentCount >= 1) { return(RedirectToAction("Index", "Departmans")); } _departmantService.Delete((int)id); return(RedirectToAction("Index", "Departmans")); }