/// <summary>
        /// Generic REST call for list objects.
        /// </summary>
        /// <typeparam name="E">Object Type.</typeparam>
        /// <typeparam name="T">Collection Object Type.</typeparam>
        /// <param name="rc">REST client.</param>
        /// <param name="rp">REST properties for request.</param>
        /// <returns>Multiple object response for a REST call.</returns>
        internal ResponseMulti <E> MakeAllRequest <E, T>(RestClient rc, RestProperties rp) where T : ICollectionType <E, T>, new()
        {
            CheckToken(rc);

            ResponseMulti <E> output  = new ResponseMulti <E>();
            RestRequest       request = RequestBuilder(rp);

            var response = rc.Execute <T>(request);

            try
            {
                if (rp.RestHeader.HasPaging())
                {
                    NavigationLastPage = NavigationLastPage = int.Parse(response.Headers.ToList()
                                                                        .Find(x => x.Name.Equals("navigationLastPage", StringComparison.CurrentCultureIgnoreCase))
                                                                        .Value.ToString());
                }
                output.Data       = response.Data.GetObjects.GetObject;
                output.Json       = response.Content;
                output.Xml        = Util.ConvertJson2Xml(response.Content);
                output.StatusCode = (int)response.StatusCode;
                output.Message    = response.StatusDescription;
                output.Header     = Util.BuildHeader(response);
            }
            catch (Exception)
            {
                output.Data       = null;
                output.Json       = null;
                output.Xml        = null;
                output.StatusCode = (int)response.StatusCode;
                output.Message    = response.StatusDescription;
                output.Header     = Util.BuildHeader(response);
            }
            return(output);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns Calendars associated to a specific School by refId
        /// </summary>
        /// <param name="refId"></param>
        /// <returns></returns>
        public ResponseMulti<XCalendarType> GetXCalendarsByXSchool(string refId)
        {
            ResponseMulti<XCalendarType> output = new ResponseMulti<XCalendarType>();

            RestRequest request = new RestRequest("xSchools/{refId}/xCalendars", Method.GET);
            request.AddParameter("refId", refId, ParameterType.UrlSegment);
            request.AddHeader("Accept", "application/json");

            var response = restClient.Execute<XCalendarCollectionType>(request);

            try
            {
                output.Data = response.Data.xCalendars.xCalendar;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }
            catch (Exception)
            {
                output.Data = null;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }

            return output;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Request all Calendars
        /// </summary>
        /// <param name="navigationPage"></param>
        /// <param name="navigationPageSize"></param>
        /// <returns></returns>
        public ResponseMulti<XCalendarType> GetXCalendars(int? navigationPage, int? navigationPageSize)
        {
            ResponseMulti<XCalendarType> output = new ResponseMulti<XCalendarType>();

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

            var response = restClient.Execute<XCalendarCollectionType>(request);

            try
            {
                output.Data = response.Data.xCalendars.xCalendar;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }
            catch (Exception)
            {
                output.Data = null;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }

            return output;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Return generated contact usernames and passwords by school
        /// </summary>
        /// <param name="refId"></param>
        /// <returns></returns>
        private ResponseMulti<XContactType> GetXContactUsers(string refId)
        {
            ResponseMulti<XContactType> output = new ResponseMulti<XContactType>();

            RestRequest request = new RestRequest("xSchools/{refId}/xContacts", Method.GET);
            request.AddParameter("refId", refId, ParameterType.UrlSegment);
            request.AddQueryParameter("getUsers", "true");
            request.AddHeader("Accept", "application/json");

            var response = restClient.Execute<XContactCollectionType>(request);
            Console.WriteLine(response.ResponseUri);
            try
            {
                output.Data = response.Data.xContacts.xContact;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }
            catch (Exception)
            {
                output.Data = null;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }

            return output;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns Students associated to a specific Staff by refId
        /// </summary>
        /// <param name="refId"></param>
        /// <param name="navigationPage"></param>
        /// <param name="navigationPageSize"></param>
        /// <returns></returns>
        public ResponseMulti<XStudentType> GetXStudentsByXStaff(string refId, int? navigationPage, int? navigationPageSize)
        {
            ResponseMulti<XStudentType> output = new ResponseMulti<XStudentType>();

            RestRequest request = new RestRequest("xStaffs/{refId}/xStudents", Method.GET);
            request.AddParameter("refId", refId, ParameterType.UrlSegment);
            request.AddHeader("Accept", "application/json");
            request.AddHeader("navigationPage", navigationPage.ToString());
            request.AddHeader("navigationPageSize", navigationPageSize.ToString());

            var response = restClient.Execute<XStudentCollectionType>(request);

            try
            {
                output.Data = response.Data.xStudents.xStudent;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }
            catch (Exception)
            {
                output.Data = null;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }

            return output;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Request all Students
        /// </summary>
        /// <returns></returns>
        public ResponseMulti<XStudentType> GetXStudents()
        {
            ResponseMulti<XStudentType> output = new ResponseMulti<XStudentType>();

            RestRequest request = new RestRequest("xStudents", Method.GET);
            request.AddHeader("Accept", "application/json");

            var response = restClient.Execute<XStudentCollectionType>(request);

            try
            {
                output.Data = response.Data.xStudents.xStudent;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }
            catch (Exception)
            {
                output.Data = null;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }

            return output;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Delete generated student passwords by school
        /// </summary>
        /// <param name="refId"></param>
        /// <returns></returns>
        public ResponseMulti<XStudentType> DeleteXStudentUsers(string refId)
        {
            ResponseMulti<XStudentType> output = new ResponseMulti<XStudentType>();

            RestRequest request = new RestRequest("xSchools/{refId}/xStudents", Method.GET);
            request.AddParameter("refId", refId, ParameterType.UrlSegment);
            request.AddQueryParameter("deleteUsers", "true");
            request.AddHeader("Accept", "application/json");

            var response = restClient.Execute<XStudentCollectionType>(request);

            try
            {
                output.Data = response.Data.xStudents.xStudent;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }
            catch (Exception)
            {
                output.Data = null;
                output.StatusCode = (int)response.StatusCode;
                output.Message = response.StatusDescription;
                output.Header = Util.BuildHeader(response);
            }

            return output;
        }