public IActionResult Get(int departmentId) { try { Department department = _departmentsService.Get(departmentId); IEnumerable <Employee> employees = _employeesService.GetAll(departmentId); // If the department does not exist, returns 404. if (department == null) { return(NotFound("Department not found.")); } // If no employees are found for the required department, returns 404. if (!employees.Any()) { return(NotFound($"No employees available for the specified department: {department.Name}")); } return(Ok(new GetAllEmployeesByDepartmentResponse { Department = department, Employees = employees })); } catch (Exception ex) { _logger.LogError(ex, "Error on getting all employees by department: {0}", departmentId); throw ex; } }