示例#1
0
        //Search administrators that contain the criteria specified and eturns their names, emails, privileges and user id's
        public AdminPagingQuery searchAdministrators(int index, String criteria)
        {
            AdminPagingQuery page = new AdminPagingQuery();

            try
            {
                using (conferenceadminContext context = new conferenceadminContext())
                {
                    int pageSize = 10;
                    //Gets list of administrators containing the criteria in their: name, email, privilege.
                    var query = context.claims.Where(admin => (admin.deleted != true && admin.privilege.privilegestType != "Master" && admin.privilege.privilegestType != "Evaluator") && ((admin.user.firstName.ToLower() + " " + admin.user.lastName.ToLower()).Contains(criteria.ToLower()) || admin.user.membership.email.ToLower().Contains(criteria.ToLower()))).Select(admin => new AdministratorQuery
                    {
                        userID = (long)admin.userID,
                        firstName = admin.user.firstName,
                        lastName = admin.user.lastName,
                        email = admin.user.membership.email,
                        privilege = admin.privilege.privilegestType == "Admin" ? "Administrator" : admin.privilege.privilegestType == "CommitteEvaluator" ? "Committee Evaluator" : admin.privilege.privilegestType,
                        privilegeID = (int)admin.privilegesID

                    }).OrderBy(x => x.userID);

                    page.rowCount = query.Count();
                    if (page.rowCount > 0)
                    {
                        page.maxIndex = (int)Math.Ceiling(page.rowCount / (double)pageSize);
                        var administrators = query.Skip(pageSize * index).Take(pageSize).ToList(); //Skip past rows and take new elements
                        page.results = administrators;
                    }

                    return page;
                }
            }
            catch (Exception ex)
            {
                Console.Write("AdminManager.searchAdministrators error " + ex);
                return null;
            }
        }
示例#2
0
        //Gets the list of administrators of the list with: name, email, privilege and user id
        public AdminPagingQuery getAdministratorList(int index)
        {
            AdminPagingQuery page = new AdminPagingQuery();

            try
            {
                using (conferenceadminContext context = new conferenceadminContext())
                {
                    int pageSize = 10;
                    //Get administrator info
                    var query = context.claims.Where(admin => admin.deleted != true && admin.privilege.privilegestType != "Master" && admin.privilege.privilegestType != "Evaluator").Select(admin => new AdministratorQuery
                    {
                        userID = (long)admin.userID,
                        firstName = admin.user.firstName,
                        lastName = admin.user.lastName,
                        email = admin.user.membership.email,
                        privilege = admin.privilege.privilegestType == "Admin" ? "Administrator" : admin.privilege.privilegestType == "CommitteEvaluator" ? "Committee Evaluator" : admin.privilege.privilegestType,
                        privilegeID = (int)admin.privilegesID

                    }).OrderBy(x => x.userID);

                    //Paging: Depending on the index value (which represents a page number) filters the results to the adequeate pageSize
                    page.rowCount = query.Count();
                    if (page.rowCount > 0)
                    {
                        page.maxIndex = (int)Math.Ceiling(page.rowCount / (double)pageSize);
                        var administrators = query.Skip(pageSize * index).Take(pageSize).ToList(); //Skip past rows and take new elements
                        page.results = administrators;
                    }

                    return page;
                }
            }
            catch (Exception ex)
            {
                Console.Write("AdminManager.getAdministratorList error " + ex);
                return null;
            }
        }