コード例 #1
0
        public static OutgoingVenueItems Parse(VenueItems x)
        {
            if (x == null)
            {
                return(null);
            }

            return(new OutgoingVenueItems
            {
                Id = x.Id,
                Name = x.Name,
                Price = x.Price,
                Type = OutgoingVenueItemType.Parse(x.ItemTypes),
                IconId = x.IconId,
                Icon = OutgoingIcon.Parse(x.Icons),
                IsHidden = x.IsHidden
            });
        }
コード例 #2
0
        public VenueItems CreateItem(string userId, CreateItem addItem)
        {
            var venueId = addItem.VenueId;

            var hotelId = this.unitOfWork.Venues.GetVenueById(userId, venueId)?.HotelId;

            if (hotelId == null)
            {
                throw new UnauthorizedAccessException();
            }

            var canAdd = this.CanUserAddVenueItems(userId, hotelId ?? -1);

            if (canAdd == false)
            {
                throw new UnauthorizedAccessException();
            }

            var newItem = new VenueItems
            {
                Name     = addItem.Name,
                Type     = addItem.ItemTypeId,
                VenueId  = addItem.VenueId,
                Price    = addItem.Price,
                IconId   = addItem.IconId,
                IsHidden = addItem.IsHidden
            };

            var quantityItem = new VenueItemQuantity
            {
                DateEffective = DateTime.UtcNow.Date,
                Quantity      = addItem.NormalQuantity
            };

            newItem.VenueItemQuantity.Add(quantityItem);

            this.dbContext.VenueItems.Add(newItem);

            return(newItem);
        }
コード例 #3
0
        //load the venue data for selected store
        public async void loadVenueData(Grid venueGrid, ProgressBar progressBar, string venueId)
        {
            //bool for errors
            bool error = false;
            //variable to hold json response
            string response = null;
            //url
            string url = "https://api.foursquare.com/v2/venues/" + venueId + "?oauth_token=" + App.accessToken + "&v=" + App.date;

            //try catch block around our network request
            try
            {
                response = await client.GetStringAsync(url);
            }
            catch
            {
                //catch error and set to true
                error = true;
            }

            //if there is no error then deserialize the content
            if (!error)
            {
                //bool for json errors
                bool jsonError = false;
                //variable to deserialize to
                VenueClass.RootObject vc = null;

                try
                {
                    vc = JsonConvert.DeserializeObject <VenueClass.RootObject>(response);
                }
                catch
                {
                    jsonError = true;
                }

                //if there was no error then continue
                if (!jsonError)
                {
                    //we will only add a couple of pictures to our photo list to avoid having to download all photos
                    //lets limit it to 3 photos
                    if (vc.response.venue.photos.count > 3)
                    {
                        for (int x = 0; x < 3; x++)
                        {
                            PhotoItems.Add(new VenuePhotoItem()
                            {
                                //we use hard code zero just because group 0 is venue photos
                                image = vc.response.venue.photos.groups[0].items[x].prefix + "original" + vc.response.venue.photos.groups[0].items[x].suffix
                            });
                        }
                    }

                    //next add our tips to the tips list
                    //we can add them all since text is light and we wont need to download from internet like photos
                    //hard code 0 because 0 is other tips
                    for (int x = 0; x < vc.response.venue.tips.groups[0].items.Count; x++)
                    {
                        TipItems.Add(new VenueTipItem()
                        {
                            userId   = vc.response.venue.tips.groups[0].items[x].user.id,
                            userName = vc.response.venue.tips.groups[0].items[x].user.firstName + " " + vc.response.venue.tips.groups[0].items[x].user.lastName,
                            comment  = vc.response.venue.tips.groups[0].items[x].text
                        });
                    }

                    VenueItem temp = new VenueItem();
                    //now we just set our variables up
                    temp.MayorName       = vc.response.venue.mayor.user.firstName + " " + vc.response.venue.mayor.user.lastName;
                    temp.MayorImage      = vc.response.venue.mayor.user.photo.prefix + "64x64" + vc.response.venue.mayor.user.photo.suffix;
                    temp.CategoryName    = vc.response.venue.categories.First().name;
                    temp.CategoryImage   = vc.response.venue.categories.First().icon.prefix + "bg_64" + vc.response.venue.categories.First().icon.suffix;
                    temp.Rating          = vc.response.venue.rating;
                    temp.Likes           = vc.response.venue.likes.count;
                    temp.CheckInStats    = vc.response.venue.stats.checkinsCount;
                    temp.CheckInVisitors = vc.response.venue.stats.usersCount;
                    temp.Longitude       = vc.response.venue.location.lng;
                    temp.Latitude        = vc.response.venue.location.lat;
                    temp.description     = vc.response.venue.description;
                    temp.venueName       = vc.response.venue.name;

                    VenueItems.Add(temp);

                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        venueGrid.Visibility   = Visibility.Visible;
                        progressBar.IsEnabled  = false;
                        progressBar.Visibility = Visibility.Collapsed;
                    });

                    setMapToLastVisitedLocation(new GeoCoordinate()
                    {
                        Longitude = singleVenueItem.Longitude, Latitude = singleVenueItem.Latitude
                    }, MyMap);
                }
            }
        }