Esempio n. 1
0
        /// <summary>
        /// Gets the employees.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public EmployeeResponse GetEmployees(EmployeeRequest request)
        {
            var response = new EmployeeResponse();

            if (request.LoadOptions.Contains("Employees"))
            {
                if (request.LoadOptions.Contains("Department"))
                {
                    if (request.LoadOptions.Contains("ListId"))
                    {
                        if (request.LoadOptions.Contains("MonthDate"))
                        {
                            string[] stringSeparators         = new string[] { "," };
                            string[] lstDepartment            = request.ListDepartmentId.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
                            List <EmployeeEntity> lstEmployee = new List <EmployeeEntity>();
                            foreach (string department in lstDepartment)
                            {
                                List <EmployeeEntity> lstgetEmployee = EmployeeDao.GetEmployeesByDepartmentIdAndMonth(true, department, request.MonthDate, request.OptionType, request.CalceType);
                                if (lstgetEmployee.Count > 0)
                                {
                                    foreach (var it in lstgetEmployee)
                                    {
                                        lstEmployee.Add(it);
                                    }
                                }
                            }

                            response.Employees = lstEmployee;
                        }
                        else
                        {
                            response.Employees = EmployeeDao.GetEmployeesByDepartmentId(true, request.ListDepartmentId);
                        }
                    }
                    else
                    {
                        if (request.LoadOptions.Contains("IsActive"))
                        {
                            response.Employees = EmployeeDao.GetActiveEmployeesByDepartmentId(request.DepartmentId);
                        }
                        else
                        {
                            response.Employees = EmployeeDao.GetEmployeesByDepartmentId(request.DepartmentId);
                        }
                    }
                }
                else
                {
                    if (request.LoadOptions.Contains("RefdateSalary"))
                    {
                        response.Employees = EmployeeDao.GetEmployeesForSalary(request.RefdateSalary, request.RefNo);
                    }
                    else
                    {
                        if (request.LoadOptions.Contains("IsActive"))
                        {
                            response.Employees = EmployeeDao.GetEmployeesByActive(true);
                        }
                        else
                        {
                            response.Employees = EmployeeDao.GetEmployees();
                        }
                    }
                    if (request.LoadOptions.Contains("RefNoAndMonthDate"))//Lấy các nhân viên theo số chứng từ lương
                    {
                        response.Employees = EmployeeDao.GetEmployeesForSalaryInMonthAndRefNo(request.MonthDate, request.RefNo);
                    }

                    if (request.LoadOptions.Contains("IsRetailEmployeePayroll"))//Lấy các nhân viên theo số chứng từ lương
                    {
                        response.Employees = EmployeeDao.GetEmployeesIsRetail(request.MonthDate, request.IsRetail);
                    }
                }
            }
            if (request.LoadOptions.Contains("Employee"))
            {
                response.Employee = EmployeeDao.GetEmployee(request.EmployeeId);
                if (request.LoadOptions.Contains("EmployeePayItem"))
                {
                    response.Employee.EmployeePayItems = EmployeePayItemDao.GetEmployeePayItemsByEmployeeId(request.EmployeeId);
                }

                if (request.LoadOptions.Contains("EmployeeForEditPayItem"))
                {
                    response.Employee.EmployeePayItems = EmployeePayItemDao.GetEmployeeForEditPayItemsByEmployeeId(request.EmployeeId);
                }

                if (request.LoadOptions.Contains("ViewSalaryEmployeePayItem"))
                {
                    response.Employee.EmployeePayItems = EmployeePayItemDao.GetEmployeeForViewtEmployeePayItem(request.EmployeeId, request.RefdateSalary, request.ExchangeRate);
                }
            }

            return(response);
        }