/// <summary>
        /// Returns a list of users by specific parameters
        /// </summary>
        public List<Domain.User> GetList(UserListParameters requestParameters)
        {
            // Build request URL
            List<string> requestUrlParameters = new List<string>();

            if (requestParameters.UserId != null) requestUrlParameters.Add("user_id=" + requestParameters.UserId);

            if (requestParameters.Search != null) requestUrlParameters.Add("search=" + HttpUtility.UrlEncode(requestParameters.Search));

            if (requestParameters.OrderBy != UserListSort.DisplayName) requestUrlParameters.Add("orderby=" + RequestValues.Get(requestParameters.OrderBy));
            if (requestParameters.Order != GenericSort.Descending) requestUrlParameters.Add("order=" + RequestValues.Get(requestParameters.Order));

            if (requestParameters.PageOffset != null) requestUrlParameters.Add("p=" + requestParameters.PageOffset);
            if (requestParameters.Size != null) requestUrlParameters.Add("size=" + requestParameters.Size);

            // Do the request
            MessageReceivingEndpoint requestMessage = new MessageReceivingEndpoint(_provider.GetRequestUrl("/api/user/list", requestUrlParameters), HttpDeliveryMethods.GetRequest);

            XPathNavigator responseMessage = _provider.DoRequest(requestMessage);
            if (responseMessage == null) return null;

            // List all the videos
            XPathNodeIterator users = responseMessage.Select("/response/user");
            List<Domain.User> result = new List<Domain.User>();

            while (users.MoveNext())
            {
                if (users.Current == null) return null;

                // Create the domain User
                Domain.User userModel = new Domain.User
                                            {
                                                UserId = Helpers.ConvertStringToInteger(users.Current.GetAttribute("user_id", "")),
                                                Username = users.Current.GetAttribute("username", ""),
                                                DisplayName = users.Current.GetAttribute("display_name", ""),
                                                URL = users.Current.GetAttribute("url", ""),
                                                FullName = users.Current.GetAttribute("full_name", ""),
                                                Email = users.Current.GetAttribute("email", ""),
                                                SiteAdmin = (users.Current.GetAttribute("site_admin", "") != "f"),
                                                AboutAbstract = Helpers.GetNodeChildValue(users.Current, "about_abstract")
                                            };

                result.Add(userModel);
            }

            return result;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a list of users by specific parameters
        /// </summary>
        public List <Domain.User> GetList(UserListParameters requestParameters)
        {
            // Build request URL
            List <string> requestUrlParameters = new List <string>();

            if (requestParameters.UserId != null)
            {
                requestUrlParameters.Add("user_id=" + requestParameters.UserId);
            }

            if (requestParameters.Search != null)
            {
                requestUrlParameters.Add("search=" + HttpUtility.UrlEncode(requestParameters.Search));
            }

            if (requestParameters.OrderBy != UserListSort.DisplayName)
            {
                requestUrlParameters.Add("orderby=" + RequestValues.Get(requestParameters.OrderBy));
            }
            if (requestParameters.Order != GenericSort.Descending)
            {
                requestUrlParameters.Add("order=" + RequestValues.Get(requestParameters.Order));
            }

            if (requestParameters.PageOffset != null)
            {
                requestUrlParameters.Add("p=" + requestParameters.PageOffset);
            }
            if (requestParameters.Size != null)
            {
                requestUrlParameters.Add("size=" + requestParameters.Size);
            }

            // Do the request
            MessageReceivingEndpoint requestMessage = new MessageReceivingEndpoint(_provider.GetRequestUrl("/api/user/list", requestUrlParameters), HttpDeliveryMethods.GetRequest);

            XPathNavigator responseMessage = _provider.DoRequest(requestMessage);

            if (responseMessage == null)
            {
                return(null);
            }

            // List all the videos
            XPathNodeIterator  users  = responseMessage.Select("/response/user");
            List <Domain.User> result = new List <Domain.User>();

            while (users.MoveNext())
            {
                if (users.Current == null)
                {
                    return(null);
                }

                // Create the domain User
                Domain.User userModel = new Domain.User
                {
                    UserId        = Helpers.ConvertStringToInteger(users.Current.GetAttribute("user_id", "")),
                    Username      = users.Current.GetAttribute("username", ""),
                    DisplayName   = users.Current.GetAttribute("display_name", ""),
                    URL           = users.Current.GetAttribute("url", ""),
                    FullName      = users.Current.GetAttribute("full_name", ""),
                    Email         = users.Current.GetAttribute("email", ""),
                    SiteAdmin     = (users.Current.GetAttribute("site_admin", "") != "f"),
                    AboutAbstract = Helpers.GetNodeChildValue(users.Current, "about_abstract")
                };

                result.Add(userModel);
            }

            return(result);
        }