public List <PeoplePickerUser> PostPeoplePickerData(PeoplePickerDataRequest peoplePickerDataRequest)
        {
            var currentUser   = GetCurrentUser();
            var userPickers   = new List <PeoplePickerUser>();
            var employeeeList = new List <EmployeeInfo>();

            var employeePositionList = new List <Biz.Models.EmployeePosition>();

            if (peoplePickerDataRequest.EmployeePositions != null)
            {
                employeePositionList.AddRange(peoplePickerDataRequest.EmployeePositions.Select(item => new Biz.Models.EmployeePosition {
                    Code = item.Code, Name = item.Name, PositionName = item.PositionName, VietnameseName = item.VietnameseName
                }));
            }

            if (currentUser.EmployeePosition == (int)StringConstant.EmployeePosition.DepartmentHead || currentUser.EmployeePosition == (int)StringConstant.EmployeePosition.BOD)
            {
                employeeeList = _employeeInfoDAL.GetAccountByFullNamePosition(peoplePickerDataRequest.Name, string.Empty, employeePositionList);
            }
            else
            {
                employeeeList = _employeeInfoDAL.GetAccountByFullNamePosition(peoplePickerDataRequest.Name, currentUser.Department.LookupValue, employeePositionList);
            }
            foreach (var employeee in employeeeList)
            {
                var peoplePickerUser = new PeoplePickerUser();
                peoplePickerUser.Email = employeee.Email;
                peoplePickerUser.Login = employeee.ADAccount.UserName;
                peoplePickerUser.Name  = employeee.FullName;
                peoplePickerUser.ID    = employeee.ID.ToString();
                userPickers.Add(peoplePickerUser);
            }
            return(userPickers);
        }
Beispiel #2
0
        public List <PeoplePickerUser> PostPeoplePickerData(PeoplePickerDataRequest peoplePickerDataRequest)
        {
            var currentUser   = GetCurrentUser();
            var userPickers   = new List <PeoplePickerUser>();
            var employeeeList = new List <EmployeeInfo>();

            if (currentUser.EmployeePosition == (int)StringConstant.EmployeePosition.DepartmentHead || currentUser.EmployeePosition == (int)StringConstant.EmployeePosition.BOD)
            {
                employeeeList = _employeeInfoDAL.GetAccountByFullNamePosition(peoplePickerDataRequest.Name, string.Empty, peoplePickerDataRequest.EmployeePositions);
            }
            else
            {
                employeeeList = _employeeInfoDAL.GetAccountByFullNamePosition(peoplePickerDataRequest.Name, currentUser.Department.LookupValue, peoplePickerDataRequest.EmployeePositions);
            }
            foreach (var employeee in employeeeList)
            {
                var peoplePickerUser = new PeoplePickerUser();
                peoplePickerUser.Email = employeee.Email;
                peoplePickerUser.Login = employeee.ADAccount.UserName;
                peoplePickerUser.Name  = employeee.FullName;
                peoplePickerUser.ID    = employeee.ID.ToString();
                userPickers.Add(peoplePickerUser);
            }
            return(userPickers);
        }
        public List <PeoplePickerUser> GetAdditionalApprovers(PeoplePickerDataRequest peoplePickerDataRequest)
        {
            var userPickers = new List <PeoplePickerUser>();

            if (peoplePickerDataRequest.EmployeePositions != null && peoplePickerDataRequest.EmployeePositions.Count > 0)
            {
                EmployeeInfo approver = _employeeInfoDAL.GetByID(Convert.ToInt32(peoplePickerDataRequest.EmployeePositions[0].PositionName));
                if (approver != null)
                {
                    var retObj = new List <EmployeeInfo>();
                    if (approver.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.BOD)
                    {
                        retObj = _employeeInfoDAL.GetAccountByFullNamePositionDepartment(peoplePickerDataRequest.Name, new List <int>()
                        {
                            (int)StringConstant.EmployeePosition.BOD
                        }, null);
                    }
                    else if (approver.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.DepartmentHead)
                    {
                        retObj = _employeeInfoDAL.GetAccountByFullNamePositionDepartment(peoplePickerDataRequest.Name, new List <int>()
                        {
                            (int)StringConstant.EmployeePosition.GroupLeader
                        }, approver.Department.LookupId);
                    }
                    else if (approver.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.TeamLeader)
                    {
                        retObj = _employeeInfoDAL.GetAccountByFullNamePositionDepartment(peoplePickerDataRequest.Name, new List <int>()
                        {
                            (int)StringConstant.EmployeePosition.AssociateTeamLeader
                        }, approver.Department.LookupId);
                    }
                    else if (approver.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.ShiftLeader)
                    {
                        retObj = _employeeInfoDAL.GetAccountByFullNamePositionDepartment(peoplePickerDataRequest.Name, new List <int>()
                        {
                            (int)StringConstant.EmployeePosition.ShiftLeader
                        }, approver.Department.LookupId);
                    }

                    foreach (var additionalApprover in retObj)
                    {
                        var peoplePickerUser = new PeoplePickerUser();
                        peoplePickerUser.Email = additionalApprover.Email;
                        peoplePickerUser.Login = additionalApprover.ADAccount.UserName;
                        peoplePickerUser.Name  = additionalApprover.FullName;
                        peoplePickerUser.ID    = additionalApprover.ID.ToString();
                        userPickers.Add(peoplePickerUser);
                    }
                }
            }

            return(userPickers);
        }