Beispiel #1
0
        public IList<IUser> getEmployees(string match, bool activeOnly)
        {
            UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());
            EmployeeMgr employeeMgr = new EmployeeMgr(ConsoleFactory.getEmployeeSvc());
            IList<IEmployee> list = employeeMgr.getUserList(activeOnly).Cast<IEmployee>().ToList();
            IList<IUser> userList = userMgr.getAllUsers().Where(x => x.Name.ToLower().Contains(match.ToLower())).ToList();

            IList<IUser> users = (from a in list
                                  join e in userList
                                  on a.ID equals e.EmployeeID
                                  select e).ToList();
            return users;
        }
Beispiel #2
0
        public JsonResult PeopleList(string input)
        {
            List<string[]> searchReturn = new List<string[]>();
            if (input != null) {
                UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());

                // get users that match and are active employees within the last 60 days
                List<IUser> userList = userMgr.getAllUsers().Where(x => x.TermDate == null || x.TermDate >= DateTime.Today.AddDays(-60)).ToList();
                foreach (IUser user in userList.Where(x => x.Name.ToLower().Contains(input.ToLower())).OrderBy(y => y.Name)) {
                    string[] returnstuff = { user.EmployeeID.ToString(), getNearSearchHtml(user.Name, input) };
                    searchReturn.Add(returnstuff);
                }
            }

            return Json(searchReturn, JsonRequestBehavior.AllowGet);
        }
Beispiel #3
0
        public IEmployee createEmployee(int employeeID)
        {
            UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());
            IUser user;
            if (!userMgr.getAllUsers().Any(x => x.EmployeeID == employeeID))
                throw new ArgumentException(employeeID + " is not a valid employeeID.");

            user = userMgr.getUser(employeeID);
            int? groupManagerID = groupManagerList.Data
                                    .Where(x => x.ID == user.ManagerID).FirstOrDefault().ID;

            if (groupManagerID == null) {              // Create Group in repository
                GroupManager groupManager = createGroupManager((int)user.ManagerID);
                this.groupManagerList.Data.Add(groupManager);
                HttpContext.Current.Application["GroupManager"] = this.groupManagerList;
                groupManagerID = groupManager.ID;
            }

            Employee employee = new Employee(user, DateTime.Today, null, (int)groupManagerID);
            this.employeeList.Data.Add(this.repository.saveEmployee(employee));
            HttpContext.Current.Application["Employee"] = this.employeeList;
            return employee;
        }
Beispiel #4
0
        public GroupManager createGroupManager(int employeeID)
        {
            UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());
            IUser user = userMgr.getUser(employeeID);

            int? groupID = getGroupList(true)
                                .Where(x => x.ID == employeeID)
                                .Select(y => y.GroupID)
                                .FirstOrDefault();
            int? directorID = getDirectorList(true)
                                .Where(x => x.ID == user.ManagerID)
                                .Select(y => y.ID)
                                .FirstOrDefault();

            if (groupID == null)
                groupID = createGroup(user.DeptName).ID;

            if (directorID == null) {
                int? temp = userMgr.getAllUsers().Where(x => x.EmployeeID == groupID).Select(y => y.ManagerID).FirstOrDefault();
                directorID = createDirector((int)temp).ID;
            }

            GroupManager groupManager = this.repository.saveGroupManager((int)groupID, employeeID, (int)directorID);
            this.groupManagerList.Data.Add(groupManager);
            HttpContext.Current.Application.Add("GroupManager", groupManagerList);

            return groupManager;
        }