Example #1
0
        private static List <Requisition> GetRequisitionsWithObjects(List <Requisition> list)
        {
            if (null == list || list.Count == 0)
            {
                return(list);
            }

            List <Requisition> requisitions = new List <Requisition>();
            List <long>        empIds       = new List <long>();

            foreach (Requisition req in list)
            {
                empIds.Add(req.Employee.EmpId);
            }

            List <Employee> employees = EmployeeDAO.GetEmployeesByIdList(empIds);

            if (employees.Count != 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].Employee = employees.Find(e => e.EmpId == list[i].Employee.EmpId);
                }
            }
            List <long> depIds = new List <long>();

            foreach (Requisition req in list)
            {
                depIds.Add(req.Employee.Department.DeptId);
            }
            List <Department> departments = DepartmentDAO.GetDepartmentsByIdList(depIds);

            if (employees.Count != 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].Employee.Department = departments.Find(e => e.DeptId == list[i].Employee.Department.DeptId);
                }
            }
            return(list);
        }