示例#1
0
        /// <summary>
        /// Returns a list of albums by specific parameters
        /// </summary>
        public List<Domain.Album> GetList(AlbumListParameters requestParameters)
        {
            // Build request URL
            List<string> requestUrlParameters = new List<string>();

            if (requestParameters.AlbumId != null) requestUrlParameters.Add("album_id=" + requestParameters.AlbumId);
            if (requestParameters.UserId != null) requestUrlParameters.Add("user_id=" + requestParameters.UserId);
            if (requestParameters.PhotoId != null) requestUrlParameters.Add("photo_id=" + requestParameters.PhotoId);

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

            if (requestParameters.IncludeHidden) requestUrlParameters.Add("include_hidden_p=1");

            if (requestParameters.OrderBy != AlbumListSort.CreationDate) 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/album/list", requestUrlParameters), HttpDeliveryMethods.GetRequest);

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

            // List all the videos
            XPathNodeIterator albums = responseMessage.Select("/response/album");
            List<Domain.Album> result = new List<Domain.Album>();

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

                // Create the domain album
                Domain.Album albumModel = new Domain.Album
                                              {
                                                  AlbumId = Helpers.ConvertStringToInteger(albums.Current.GetAttribute("album_id", "")),

                                                  Title = albums.Current.GetAttribute("title", ""),

                                                  PrettyDate = albums.Current.GetAttribute("pretty_date", ""),
                                                  PrettyTime = albums.Current.GetAttribute("pretty_time", ""),

                                                  One = albums.Current.GetAttribute("one", ""),
                                                  CreationDateANSI = albums.Current.GetAttribute("creation_date_ansi", ""),

                                                  UserId = Helpers.ConvertStringToInteger(albums.Current.GetAttribute("user_id", "")),
                                                  UserUrl = albums.Current.GetAttribute("user_url", ""),
                                                  Username = albums.Current.GetAttribute("username", ""),
                                                  DisplayName = albums.Current.GetAttribute("display_name", ""),

                                                  Token = albums.Current.GetAttribute("token", ""),
                                                  Hide = (albums.Current.GetAttribute("hide_p", "") == "1"),

                                                  Content = Helpers.GetNodeChildValue(albums.Current, "content"),
                                                  ContentText = Helpers.GetNodeChildValue(albums.Current, "content_text")
                                              };

                result.Add(albumModel);
            }

            return result;
        }
示例#2
0
        /// <summary>
        /// Returns a list of albums by specific parameters
        /// </summary>
        public List <Domain.Album> GetList(AlbumListParameters requestParameters)
        {
            // Build request URL
            List <string> requestUrlParameters = new List <string>();

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

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

            if (requestParameters.IncludeHidden)
            {
                requestUrlParameters.Add("include_hidden_p=1");
            }

            if (requestParameters.OrderBy != AlbumListSort.CreationDate)
            {
                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/album/list", requestUrlParameters), HttpDeliveryMethods.GetRequest);

            XPathNavigator responseMessage = _provider.DoRequest(requestMessage);

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

            // List all the videos
            XPathNodeIterator   albums = responseMessage.Select("/response/album");
            List <Domain.Album> result = new List <Domain.Album>();

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

                // Create the domain album
                Domain.Album albumModel = new Domain.Album
                {
                    AlbumId = Helpers.ConvertStringToInteger(albums.Current.GetAttribute("album_id", "")),

                    Title = albums.Current.GetAttribute("title", ""),

                    PrettyDate = albums.Current.GetAttribute("pretty_date", ""),
                    PrettyTime = albums.Current.GetAttribute("pretty_time", ""),

                    One = albums.Current.GetAttribute("one", ""),
                    CreationDateANSI = albums.Current.GetAttribute("creation_date_ansi", ""),

                    UserId      = Helpers.ConvertStringToInteger(albums.Current.GetAttribute("user_id", "")),
                    UserUrl     = albums.Current.GetAttribute("user_url", ""),
                    Username    = albums.Current.GetAttribute("username", ""),
                    DisplayName = albums.Current.GetAttribute("display_name", ""),

                    Token = albums.Current.GetAttribute("token", ""),
                    Hide  = (albums.Current.GetAttribute("hide_p", "") == "1"),

                    Content     = Helpers.GetNodeChildValue(albums.Current, "content"),
                    ContentText = Helpers.GetNodeChildValue(albums.Current, "content_text")
                };

                result.Add(albumModel);
            }

            return(result);
        }