Esempio n. 1
0
        public PlaceViewModel(PlaceObject model)
        {
            PlaceID          = model.Result.PlaceID;
            Name             = model.Result.Name;
            FormattedAddress = model.Result.FormattedAddress;
            Lat     = model.Result.Geometry.Location.Lat;
            Lng     = model.Result.Geometry.Location.Lng;
            Website = model.Result.Website;

            foreach (AddressComponent item in model.Result.AddressComponents)
            {
                switch (item.Types[0])
                {
                case "street_number":
                    StreetNumber = item.LongName;
                    break;

                case "route":
                    Route = item.LongName;
                    break;

                case "postal_code":
                    PostalCode = item.LongName;
                    break;

                case "locality":
                    City = item.LongName;
                    break;

                case "administrative_area_level_1":
                    State = item.LongName;
                    break;

                case "country":
                    Country = item.LongName;
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 2
0
        public static PlaceViewModel GetPlaceObjectt(string placeID)
        {
            try
            {
                using (WebClient client = new WebClient())
                {
                    //string result = client.DownloadString(String.Format("https://maps.googleapis.com/maps/api/place/details/json?&placeid={0}&key=AIzaSyBI5B2snURiIE8VkeuNYL2Es3ZZf8veRf4", placeID));
                    string      result     = client.DownloadString(String.Format("https://maps.googleapis.com/maps/api/place/details/json?&placeid={0}&key=AIzaSyAuQaBzbJrduma-UhUFoWNyLWfJFoR3vac", placeID));
                    PlaceObject jsonObject = JsonConvert.DeserializeObject <PlaceObject>(result);

                    PlaceViewModel placeViewModel = new PlaceViewModel(jsonObject);

                    return(placeViewModel);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 3
0
        public ReviewViewModel(Review review, PlaceObject place, File image)
        {
            ReviewID = review.ReviewID;
            UserID   = review.UserID;

            Title        = review.Title;
            Body         = review.Body;
            ResidentType = review.ResidentType;
            SubjectType  = review.Subject;
            StarRating   = review.StarRating;
            CostRating   = review.CostRating;
            DatePosted   = review.DatePosted.ToLongDateString();
            ImageID      = review.ImageID;
            FileName     = image.FileName;
            Pathname     = image.Path;


            PlaceID   = place.Result.PlaceID;
            PlaceName = place.Result.Name;
            foreach (AddressComponent item in place.Result.AddressComponents)
            {
                switch (item.Types[0])
                {
                case "locality":
                    City = item.LongName;
                    break;

                case "administrative_area_level_1":
                    State = item.LongName;
                    break;

                case "country":
                    Country = item.LongName;
                    break;

                default:
                    break;
                }
            }
        }