示例#1
0
        static void GetAllDepartments()
        {
            IDepartmentFacade departmentFacade = (IDepartmentFacade)FacadeFactory.Instance.Create(FacadeType.DepartmentManagerFacade);
            OperationResult <IList <IDepartmentDTO> > departmentDTOList = departmentFacade.GetAllDepartments();

            if (departmentDTOList.IsValid())
            {
                foreach (var department in departmentDTOList.Data)
                {
                    System.Console.WriteLine(department.DepartmentId + "\t" + department.DepartmentName);
                }
            }
        }
示例#2
0
        static void GetDepartment()
        {
            System.Console.WriteLine("Department Id : ");
            int departmentId;

            int.TryParse(System.Console.ReadLine(), out departmentId);
            IDepartmentFacade departmentFacade             = (IDepartmentFacade)FacadeFactory.Instance.Create(FacadeType.DepartmentManagerFacade);
            OperationResult <IDepartmentDTO> departmentDTO = departmentFacade.GetADepartment(departmentId);

            if (departmentDTO.IsValid())
            {
                System.Console.WriteLine(departmentDTO.Data.DepartmentId + "\t" + departmentDTO.Data.DepartmentName);
            }
        }
示例#3
0
        public ActionResult SearchEmployee(SearchEmployee searchEmployee)
        {
            ActionResult retVal = null;

            if (ModelState.IsValid)
            {
                ISearchEmployeeDTO searchEmployeeDTO = (ISearchEmployeeDTO)DTOFactory.Instance.Create(DTOType.SearchEmployeeDTO);
                DTOConverter.FillDTOFromViewModel(searchEmployeeDTO, searchEmployee);

                IUserFacade userFacade = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserManagerFacade);
                OperationResult <IList <IEmployeeDTO> > result = userFacade.SearchEmployeeByRawQuery(searchEmployeeDTO, (User.IsInRole("NonAdmin"))?true:false);

                if (result.IsValid())
                {
                    IList <Employee> employeeList = new List <Employee>();
                    Employee         employee     = null;

                    IDepartmentFacade departmentFacade = (IDepartmentFacade)FacadeFactory.Instance.Create(FacadeType.DepartmentManagerFacade);
                    //OperationResult<IList<IEmployeeDTO>> result = userFacade.SearchEmployeeByRawQuery(searchEmployeeDTO, true);

                    foreach (var employeeDTO in result.Data)
                    {
                        employee = new Employee();
                        DTOConverter.FillViewModelFromDTO(employee, employeeDTO);

                        OperationResult <IDepartmentDTO> department = departmentFacade.GetADepartment(employeeDTO.DepartmentId);
                        if (department.IsValid())
                        {
                            employee.Department = new Department();
                            DTOConverter.FillViewModelFromDTO(employee.Department, department.Data);
                        }

                        employeeList.Add(employee);
                    }

                    retVal = PartialView("~/Views/User/_SearchEmployeeList.cshtml", employeeList);
                }
                else if (result.HasFailed())
                {
                }
                else
                {
                    retVal = View("~/Views/Shared/Error.cshtml");
                }
            }
            return(retVal);
        }
示例#4
0
        private IEnumerable <SelectListItem> FillDepartmentsFromDepartmentList(int selectedDepartmentId)
        {
            IDepartmentFacade departmentFacade = (IDepartmentFacade)FacadeFactory.Instance.Create(FacadeType.DepartmentManagerFacade);
            OperationResult <IList <IDepartmentDTO> > departmentList = departmentFacade.GetAllDepartments();

            IEnumerable <SelectListItem> departments = null;

            if (departmentList.IsValid())
            {
                departments = new List <SelectListItem>();
                departments = departmentList.Data.Select(dept => new SelectListItem
                {
                    Text     = dept.DepartmentName,
                    Value    = dept.DepartmentId.ToString(),
                    Selected = (dept.DepartmentId == selectedDepartmentId) ? true : false
                });
            }
            return(departments);
        }
示例#5
0
 public DepartmentController()
 {
     this.depFac = new DepartmentFacade();
 }