Example #1
0
        /// <summary>
        /// Queries the API on nevika.taotek.dk for a product
        /// </summary>
        /// <param name="ean_code"></param>
        private async void GetProductInfo(string ean_code)
        {
            // Try and get a product
            Product product = await ProductProcessor.RequestProductInfo(ean_code);

            //my new local database method
            //product = LocalDatabase.GetProduct(ean_code);

            if (product != null)
            {
                // If the product is found, stop the loading icon and activate the other slots.
                // All of this is temporary

                ProductIconSlot.IsVisible = true;
                ProductNameSlot.IsVisible = true;
                LoadingCircle.IsRunning   = false;

                // ONLY FOR TESTING, need to implement the icons in the database first
                switch (ean_code)
                {
                case "8710398169280":
                    ProductIconSlot.Source = "Cruesli.png";
                    break;

                case "5000159461122":
                    ProductIconSlot.Source = "snickers.jpg";
                    break;

                case "25065244":
                    ProductIconSlot.Source = "Milk.jpg";
                    break;

                default:
                    ProductIconSlot.IsVisible = false;
                    break;
                }
                if (product.Product_Image != "")
                {
                    ProductIconSlot.IsVisible = true;
                    ProductIconSlot.Source    = product.Product_Image;
                }

                // If successful, apply the product information on the page
                ApplyProduct(product);
            }
            else
            {
                // Else nope.
                // All of the frontend for this page is very temporary
                ProductIconSlot.IsVisible           = true;
                ProductNameSlot.IsVisible           = true;
                LoadingCircle.IsRunning             = false;
                LoadingCircle.IsVisible             = false;
                FavoritButton.IsVisible             = false;
                Label_Allergens.IsVisible           = false;
                ProductFoundAllergensSlot.IsVisible = false;
                Label_Allergens_Title.IsVisible     = false;

                ChangeName("Varen findes ikke i databasen");
            }
        }