Esempio n. 1
0
        public Place TransformTextPlaceToPlace(GoogleTextSearchPlace gtp)
        {
            IPhotosService photoService = new GooglePhotosService();

            Place place = new Place()
            {
                Id         = gtp.PlaceId,
                Name       = gtp.Name,
                Categories = gtp.Categories,
                Rating     = gtp.Rating,
                Location   = gtp.Geometry.Location.Latitude.ToString() + " " + gtp.Geometry.Location.Longitude.ToString(),
                Address    = gtp.Address ?? "",
                Icon       = gtp.Icon ?? "",
                OpenNow    = gtp.OpenHours?.OpenNow ?? false
            };

            if (gtp.GooglePhotos == null)
            {
                place.PhotoReference = place.Icon;
                place.Photo          = place.Icon;
            }
            else
            {
                place.PhotoReference = gtp.GooglePhotos[0].PhotoReference;
                place.Photo          = photoService.GetImageByReference(place.PhotoReference, "100", "80");
            }
            return(place);
        }
Esempio n. 2
0
        public DetailedPlace TransformDetailedPlaceToPlace(DetailedGooglePlace dgp, Place place)
        {
            IPhotosService photo    = new GooglePhotosService();
            DetailedPlace  detPlace = new DetailedPlace()
            {
                Id          = dgp.PlaceId,
                Name        = dgp.Name,
                Categories  = dgp.Categories,
                Rating      = dgp.Rating,
                Location    = dgp.Geometry.Location.Latitude.ToString() + " " + dgp.Geometry.Location.Longitude.ToString(),
                Address     = place.Address,
                Icon        = place.Icon,
                OpenNow     = dgp.OpenHours?.OpenNow ?? false,
                PriceLevel  = place.PriceLevel,
                PriceString = place.PriceString,
                Reviews     = dgp.Reviews,
                PhoneNumber = dgp.PhoneNumber,
                WebSite     = dgp.WebSite,
                Photo       = photo.GetImageByReference(place.PhotoReference, "184", "400")
            };

            if (detPlace.Reviews != null)
            {
                detPlace.Author  = detPlace.Reviews.FirstOrDefault().ReviewAuthor;
                detPlace.Comment = detPlace.Reviews.FirstOrDefault().ReviewText;
            }
            return(detPlace);
        }
Esempio n. 3
0
        public Place TransformAPINerabyPlaceToPlace(GooglePlace gp)
        {
            IPhotosService photoService = new GooglePhotosService();

            var   gplace = gp;
            Place place  = new Place()
            {
                Id         = gp.PlaceId,
                Name       = gp.Name,
                Categories = gp.Categories ?? new List <string>(),
                Rating     = gp.Rating,
                Location   = gp.Geometry.Location.Latitude.ToString() + " " + gp.Geometry.Location.Longitude.ToString(),
                Address    = gp.Address ?? "",
                Icon       = gp.Icon,
                OpenNow    = gp.OpenHours?.OpenNow ?? false
            };

            if (gp.GooglePhotos == null)
            {
                place.PhotoReference = place.Icon;
                place.Photo          = place.Icon;
            }
            else
            {
                place.PhotoReference = gp.GooglePhotos[0].PhotoReference;
                place.Photo          = photoService.GetImageByReference(place.PhotoReference, "100", "80");
            }

            if (gp.PriceLevel.ToString() != "")
            {
                place.PriceLevel = gp.PriceLevel.ToString();
            }
            else
            {
                place.PriceLevel = "5";
            }

            switch (place.PriceLevel)
            {
            case "0":
                place.PriceString = "free";
                break;

            case "1":
                place.PriceString = "cheap";
                break;

            case "2":
                place.PriceString = "moderate";
                break;

            case "3":
                place.PriceString = "expensive";
                break;

            case "4":
                place.PriceString = "very expensive";
                break;

            case "5":
                place.PriceString = "unknown";
                break;
            }
            return(place);
        }