RicOneApi.Api.XPress.GetLastPage C# (CSharp) Method

GetLastPage() public method

Max page value for specified service path object
public GetLastPage ( int navigationPageSize, ServicePath p ) : int
navigationPageSize int
p ServicePath
return int
        public int GetLastPage(int navigationPageSize, ServicePath p)
        {
            string path = "";
            int navigationLastPage = 0;

            if (p == ServicePath.GetXLeas)
            {
                path = "xLeas";
            }
            else if (p == ServicePath.GetXLeasByXSchool)
            {
                path = "xSchools/{refId}/xLeas";
            }
            else if (p == ServicePath.GetXLeasByXRoster)
            {
                path = "xRosters/{refId}/xLeas";
            }
            else if (p == ServicePath.GetXLeasByXStaff)
            {
                path = "xStaffs/{refId}/xLeas";
            }
            else if (p == ServicePath.GetXLeasByXStudent)
            {
                path = "xStudents/{refId}/xLeas";
            }
            else if (p == ServicePath.GetXLeasByXContact)
            {
                path = "xContacts/{refId}/xLeas";
            }
            else if (p == ServicePath.GetXSchools)
            {
                path = "xSchools";
            }
            else if (p == ServicePath.GetXSchoolsByXLea)
            {
                path = "xLeas/{refId}/xSchools";
            }
            else if (p == ServicePath.GetXSchoolsByXCalendar)
            {
                path = "xCalendars/{refId}/xSchools";
            }
            else if (p == ServicePath.GetXSchoolsByXCourse)
            {
                path = "xCourses/{refId}/xSchools";
            }
            else if (p == ServicePath.GetXSchoolsByXRoster)
            {
                path = "xRosters/{refId}/xSchools";
            }
            else if (p == ServicePath.GetXSchoolsByXStaff)
            {
                path = "xStaffs/{refId}/xSchools";
            }
            else if (p == ServicePath.GetXSchoolsByXStudent)
            {
                path = "xStudents/{refId}/xSchools";
            }
            else if (p == ServicePath.GetXSchoolsByXContact)
            {
                path = "xContacts/{refId}/xSchools";
            }
            else if (p == ServicePath.GetXCalendars)
            {
                path = "xCalendars";
            }
            else if (p == ServicePath.GetXCalendarsByXLea)
            {
                path = "xLeas/{refId}/xCalendars";
            }
            else if (p == ServicePath.GetXCalendarsByXSchool)
            {
                path = "xSchools/{refId}/xCalendars";
            }
            else if (p == ServicePath.GetXCourses)
            {
                path = "xCourses";
            }
            else if (p == ServicePath.GetXCoursesByXLea)
            {
                path = "xLeas/{refId}/xCourses";
            }
            else if (p == ServicePath.GetXCoursesByXSchool)
            {
                path = "xSchools/{refId}/xCourses";
            }
            else if (p == ServicePath.GetXCoursesByXRoster)
            {
                path = "xRosters/{refId}/xCourses";
            }
            else if (p == ServicePath.GetXRosters)
            {
                path = "xRosters";
            }
            else if (p == ServicePath.GetXRostersByXLea)
            {
                path = "xLeas/{refId}/xRosters";
            }
            else if (p == ServicePath.GetXRostersByXSchool)
            {
                path = "xSchools/{refId}/xRosters";
            }
            else if (p == ServicePath.GetXRostersByXCourse)
            {
                path = "xCourses/{refId}/xRosters";
            }
            else if (p == ServicePath.GetXRostersByXStaff)
            {
                path = "xStaffs/{refId}/xRosters";
            }
            else if (p == ServicePath.GetXRostersByXStudent)
            {
                path = "xStudents/{refId}/xRosters";
            }
            else if (p == ServicePath.GetXStaffs)
            {
                path = "xStaffs";
            }
            else if (p == ServicePath.GetXStaffsByXLea)
            {
                path = "xLeas/{refId}/xStaffs";
            }
            else if (p == ServicePath.GetXStaffsByXSchool)
            {
                path = "xSchools/{refId}/xStaffs";
            }
            else if (p == ServicePath.GetXStaffsByXCourse)
            {
                path = "xCourses/{refId}/xStaffs";
            }
            else if (p == ServicePath.GetXStaffsByXRoster)
            {
                path = "xRosters/{refId}/xStaffs";
            }
            else if (p == ServicePath.GetXStaffsByXStudent)
            {
                path = "xStudents/{refId}/xStaffs";
            }
            else if (p == ServicePath.GetXStudents)
            {
                path = "xStudents";
            }
            else if (p == ServicePath.GetXStudentsByXLea)
            {
                path = "xLeas/{refId}/xStudents";
            }
            else if (p == ServicePath.GetXStudentsByXSchool)
            {
                path = "xSchools/{refId}/xStudents";
            }
            else if (p == ServicePath.GetXStudentsByXRoster)
            {
                path = "xRosters/{refId}/xStudents";
            }
            else if (p == ServicePath.GetXStudentsByXStaff)
            {
                path = "xStaffs/{refId}/xStudents";
            }
            else if (p == ServicePath.GetXStudentsByXContact)
            {
                path = "xContacts/{refId}/xStudents";
            }
            else if (p == ServicePath.GetXContacts)
            {
                path = "xContacts";
            }
            else if (p == ServicePath.GetXContactsByXLea)
            {
                path = "xLeas/{refId}/xContacts";
            }
            else if (p == ServicePath.GetXContactsByXSchool)
            {
                path = "xSchools/{refId}/xContacts";
            }
            else if (p == ServicePath.GetXContactsByXStudent)
            {
                path = "xStudents/{refId}/xContacts";
            }

            RestRequest request = new RestRequest(path, Method.GET);
            request.AddHeader("Accept", "application/json");
            request.AddHeader("navigationPage", "1");
            request.AddHeader("navigationPageSize", navigationPageSize.ToString());

            var response = restClient.Execute(request);

            try
            {
                navigationLastPage = Int32.Parse(response.Headers.ToList()
                .Find(x => x.Name.Equals("navigationLastPage", StringComparison.CurrentCultureIgnoreCase))
                .Value.ToString());
            }
            catch(NullReferenceException)
            {
                navigationLastPage = 0;
            }

            return navigationLastPage;
        }

Same methods

XPress::GetLastPage ( int navigationPageSize, ServicePath p, string refId ) : int

Usage Example

        static void Main(string[] args)
        {
            Authenticator auth = new Authenticator(authUrl, clientId, clientSecret); //Pass auth url, username, and password to authenticate to auth server

            foreach (Endpoint e in auth.GetEndpoints(providerId)) //For the provided endpoint
            {
                XPress xPress = new XPress(e.href); //Pass endpoint info to data API (token, href)

                foreach (XLeaType l in xPress.GetXLeas().Data) //Iterate through each xLea
                {
                    for (int i = 1; i <= xPress.GetLastPage(navigationPageSize, XPress.ServicePath.GetXRostersByXLea, l.refId); i++ ) //Get max page size for rosters by lea
                    {
                        foreach (XRosterType r in xPress.GetXRostersByXLea(l.refId, i, navigationPageSize).Data) //Get each roster for each lea refId w/ paging
                        {
                            Console.WriteLine("courseTitle: " + r.courseTitle);
                            foreach (XPersonReferenceType p in r.students.studentReference) //Students for each course
                            {
                                Console.WriteLine("refId: " + p.refId);
                                Console.WriteLine("localId: " + p.localId);
                                Console.WriteLine("givenName: " + p.givenName);
                                Console.WriteLine("familyName: " + p.familyName);
                            }
                        }
                        Console.WriteLine("######## PAGE " + i + " ########");
                    }

                }
            }

            Console.Read();
        }
All Usage Examples Of RicOneApi.Api.XPress::GetLastPage