Пример #1
0
        private Album GetAlbum()
        {
            AlbumsResource.ListRequest request  = service.Albums.List();
            ListAlbumsResponse         response = request.Execute();

            if (response.Albums != null && response.Albums.Count > 0)
            {
                bool morePages = true;

                while (response.Albums != null && response.Albums.Count > 0 && morePages)
                {
                    foreach (var album in response.Albums)
                    {
                        string alternateAlbumTitle = albumTitle.Replace("&", "&");

                        if (album.Title.Equals(albumTitle) || album.Title.Equals(alternateAlbumTitle))
                        {
                            return(album);
                        }
                    }

                    if (response.NextPageToken != null)
                    {
                        request.PageToken = response.NextPageToken;
                        response          = request.Execute();
                    }
                    else
                    {
                        morePages = false;
                    }
                }
            }

            return(null);
        }
Пример #2
0
        public async Task <ActionResult> ListAlbums(string countryKey, string cityKey)
        {
            var city = await _travelService.GetCity(countryKey, cityKey);

            if (city == null || !city.Albums.Any())
            {
                return(NotFound());
            }

            if (city.Albums.Count() == 1)
            {
                return(RedirectToAction(
                           nameof(ListPhotos),
                           new
                {
                    countryKey = city.CountryKey,
                    cityKey = city.CityKey,
                    albumKey = city.Albums[0].Key,
                }));
            }

            SetTitle($"world traveler | {city.CountryName.ToLower()} | {city.CityName.ToLower()}");
            SetKeywords(city.CountryName, city.CityName);
            SetDescription($"Pictures of my time in {city.CityName}, {city.CountryName}. {city.Description}");

            var response = new ListAlbumsResponse(city);

            return(View(response));
        }
Пример #3
0
        public void Test_ListAlbums_GetFirstAlbum()
        {
            ListAlbumsResponse listAlbumsResponse = this.googlePhotosClient.ListAlbums();

            foreach (Album album in listAlbumsResponse.Albums)
            {
                Album singleAlbum = this.googlePhotosClient.GetAlbum(album.Id);

                break;
            }
        }
Пример #4
0
        public static ListAlbumsResponse Unmarshall(UnmarshallerContext context)
        {
            ListAlbumsResponse listAlbumsResponse = new ListAlbumsResponse();

            listAlbumsResponse.HttpResponse = context.HttpResponse;
            listAlbumsResponse.Code         = context.StringValue("ListAlbums.Code");
            listAlbumsResponse.Message      = context.StringValue("ListAlbums.Message");
            listAlbumsResponse.NextCursor   = context.StringValue("ListAlbums.NextCursor");
            listAlbumsResponse.TotalCount   = context.IntegerValue("ListAlbums.TotalCount");
            listAlbumsResponse.RequestId    = context.StringValue("ListAlbums.RequestId");
            listAlbumsResponse.Action       = context.StringValue("ListAlbums.Action");

            List <ListAlbumsResponse.ListAlbums_Album> listAlbumsResponse_albums = new List <ListAlbumsResponse.ListAlbums_Album>();

            for (int i = 0; i < context.Length("ListAlbums.Albums.Length"); i++)
            {
                ListAlbumsResponse.ListAlbums_Album album = new ListAlbumsResponse.ListAlbums_Album();
                album.Id          = context.LongValue("ListAlbums.Albums[" + i + "].Id");
                album.IdStr       = context.StringValue("ListAlbums.Albums[" + i + "].IdStr");
                album.Name        = context.StringValue("ListAlbums.Albums[" + i + "].Name");
                album.State       = context.StringValue("ListAlbums.Albums[" + i + "].State");
                album.Remark      = context.StringValue("ListAlbums.Albums[" + i + "].Remark");
                album.PhotosCount = context.LongValue("ListAlbums.Albums[" + i + "].PhotosCount");
                album.Ctime       = context.LongValue("ListAlbums.Albums[" + i + "].Ctime");
                album.Mtime       = context.LongValue("ListAlbums.Albums[" + i + "].Mtime");

                ListAlbumsResponse.ListAlbums_Album.ListAlbums_Cover cover = new ListAlbumsResponse.ListAlbums_Album.ListAlbums_Cover();
                cover.Id      = context.LongValue("ListAlbums.Albums[" + i + "].Cover.Id");
                cover.IdStr   = context.StringValue("ListAlbums.Albums[" + i + "].Cover.IdStr");
                cover.Title   = context.StringValue("ListAlbums.Albums[" + i + "].Cover.Title");
                cover.FileId  = context.StringValue("ListAlbums.Albums[" + i + "].Cover.FileId");
                cover.State   = context.StringValue("ListAlbums.Albums[" + i + "].Cover.State");
                cover.Md5     = context.StringValue("ListAlbums.Albums[" + i + "].Cover.Md5");
                cover.IsVideo = context.BooleanValue("ListAlbums.Albums[" + i + "].Cover.IsVideo");
                cover.Remark  = context.StringValue("ListAlbums.Albums[" + i + "].Cover.Remark");
                cover.Width   = context.LongValue("ListAlbums.Albums[" + i + "].Cover.Width");
                cover.Height  = context.LongValue("ListAlbums.Albums[" + i + "].Cover.Height");
                cover.Ctime   = context.LongValue("ListAlbums.Albums[" + i + "].Cover.Ctime");
                cover.Mtime   = context.LongValue("ListAlbums.Albums[" + i + "].Cover.Mtime");
                album.Cover   = cover;

                listAlbumsResponse_albums.Add(album);
            }
            listAlbumsResponse.Albums = listAlbumsResponse_albums;

            return(listAlbumsResponse);
        }
        /// <summary>
        /// Get the existing Google Photos Album entry.
        /// Sets the class variable 'album' as well.
        /// </summary>
        /// <returns>Album that exists, null otherwise</returns>
        private Album SetAlbum()
        {
            if (album != null)
            {
                return(album);
            }

            AlbumsResource.ListRequest request = service.Albums.List();
            //request.PageSize = 10; //Uncommenting. Let Google decide the page size.
            ListAlbumsResponse response = request.Execute();

            string alternateAlbumTitle = albumTitle.Replace("&", "&amp;");

            while (response.Albums != null && response.Albums.Count > 0)
            {
                foreach (var albumresponse in response.Albums)
                {
                    if (albumresponse != null && albumresponse.Title != null)
                    {
                        if (albumresponse.Title.Equals(albumTitle) || albumresponse.Title.Equals(alternateAlbumTitle))
                        {
                            album = albumresponse;
                            return(albumresponse);
                        }
                    }
                }

                //Fetch next page of Albums
                if (response.NextPageToken != null)
                {
                    request.PageToken = response.NextPageToken;
                    response          = request.Execute();
                }
                else
                {
                    break;
                }
            }

            return(null);
        }