コード例 #1
0
        public async Task <string> UpdatePhotos(string placeId, int count = 2)
        {
            var details = await _googlePlaceDetailsApiClient.GetAsync(_googlePlaceDetailsInputFactory.CreatePhotoReference(placeId));

            if (InterpreteGoogleStatus.IsStatusOk(details.status))
            {
                var maxPhotoNum = 1;
                var photo       = String.Empty;
                foreach (var item in details.Result.photos)
                {
                    photo = await _googlePlacePhotosApiCaller.GetPhotoAsync(item.photo_reference, 600, null);

                    if (!String.IsNullOrWhiteSpace(photo))
                    {
                        await _placePhotoRepository.InsertAsync(new PlacePhoto(placeId, item.photo_reference, photo));
                    }
                    maxPhotoNum += 1;
                    if (maxPhotoNum >= count)
                    {
                        break;
                    }
                }

                return(photo);
            }
            else
            {
                return(String.Empty);
            }
        }