Пример #1
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            shopInfo = (GeneralInfo)e.NavigationParameter;
            if (shopInfo != null)
            {
                if (shopInfo.userFeedback == null)
                    feedbackCollection = new ObservableCollection<TransactionFeedback>();
                else
                    feedbackCollection = shopInfo.userFeedback;

                foreach(var feedback in feedbackCollection)
                {
                    if(feedback.Listing != null)
                    {
                        if(feedback.Listing.Images == null)
                            await feedback.Listing.getImages();
                        if (feedback.Listing.Images != null)
                            if (feedback.Listing.Images.Count > 0)
                                feedback.item_photo_url = feedback.Listing.Images[0].url_170x135;
                    }
                }

                ratingsListView.ItemsSource = feedbackCollection;
            }
        }
Пример #2
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            shopInfo = (GeneralInfo)e.NavigationParameter;
            if (shopInfo != null)
            {
                if (shopInfo.userFeedback == null)
                    feedbackCollection = new ObservableCollection<TransactionFeedback>();
                else
                    feedbackCollection = shopInfo.userFeedback;

                pRing.IsActive = true;                  // progress ring done manually this time
                pRing.Visibility = Visibility.Visible;

                foreach (var feedback in feedbackCollection)
                {
                    if (feedback.Listing != null)
                    {
                        if (feedback.Listing.Images == null)
                            await feedback.Listing.getImages();
                        if (feedback.Listing.Images != null)
                            if (feedback.Listing.Images.Count > 0)
                                feedback.item_photo_url = feedback.Listing.Images[0].url_170x135;
                    }
                }

                Loading.ControlProgressRing<TransactionFeedback>(shopInfo.userFeedback, pRing);     // progress ring
                ratingsListView.ItemsSource = feedbackCollection;
            }
        }
Пример #3
0
        /// <summary>
        /// Get extra detail about the given shop, including images
        /// </summary>
        /// <param name="shop"></param>
        /// <returns></returns>
        public static async Task<ShopAbout> getShopAbout(GeneralInfo shop)
        {
            HttpClient client = new HttpClient();
            string baseURL = App.baseURL, errorMessage = "";
            ShopAbout shopAbout = new ShopAbout();
            shopAbout.Images = new ObservableCollection<ShopImage>();

            if (App.logged_in == false)         // this function only applies to a logged in user
                return shopAbout;

            List<Parameter> parameters = new List<Parameter>();
            parameters.Add(new Parameter("includes", "Images"));       // get the listings' details

            baseURL = string.Format("{0}/shops/{1}/about", baseURL, shop.shop_id);
            baseURL = AuthenticationAccess.addAuthentication(baseURL, parameters, "GET");

            AboutDeserializeCapturer aDes = new AboutDeserializeCapturer();
            

            try
            {
                var jsonStream = await client.GetStreamAsync(baseURL);

                using (StreamReader reader = new StreamReader(jsonStream))
                {
                    var serializer = new DataContractJsonSerializer(typeof(AboutDeserializeCapturer));

                    aDes = (AboutDeserializeCapturer)serializer.ReadObject(jsonStream);
                    if(aDes != null)
                        if (aDes.results != null)
                            if (aDes.results.Count > 0)
                                shopAbout = aDes.results[0];
                }

            }
            catch (Exception e)
            {
                errorMessage = e.Message;
            }

            return shopAbout;
        }
Пример #4
0
        /// <summary>
        /// Send a DELETE request to remove the specified user from the logged in user's favorites 
        /// </summary>
        /// <param name="shop"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public static async Task RemoveFavoriteUser(GeneralInfo shop)
        {
            HttpClient client = new HttpClient();
            string baseURL = App.baseURL, errorMessage = "";

            if (App.logged_in == false)         // this function only applies to a logged in user
                return;

            List<Parameter> parameters = new List<Parameter>();
            parameters.Add(new Parameter("target_user_id", shop.user_id.ToString()));

            baseURL = string.Format("{0}/users/{1}/favorites/users/{2}", baseURL, App.userID, shop.user_id);
            baseURL = AuthenticationAccess.addAuthentication(baseURL, parameters, "DELETE");

            try
            {
                HttpResponseMessage response = await client.DeleteAsync(baseURL);

                var jsonString = await response.Content.ReadAsStringAsync();

                shop.isFavorite = false;
            }
            catch (Exception e)
            {
                errorMessage = e.Message;
            }
        }