Esempio n. 1
0
        public void populateItems()
        {
            tescoApiJson item = ((StockAppApplicaiton)Application).tescoApiList[position];

            itemName.Text = item.items[0].description;
            string tableName = "nutrition";

            try
            {
                string[] tempArr = { "Nutrition", item.items[0].nutrition.per100Header };
                createTableRow(tempArr, tableName);

                foreach (var subItem in item.items[0].nutrition.nutrients)
                {
                    tempArr[0] = subItem.name;
                    tempArr[1] = subItem.valuePer100;
                    createTableRow(tempArr, tableName);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                string[] tempArr = { "No Nutrition Information Provided" };
                createTableRow(tempArr, tableName);
            }

            string strIngredients = "";

            try
            {
                strIngredients += "Ingredients \n";
                foreach (var subItem in item.items[0].ingredients)
                {
                    strIngredients += subItem + "\n";
                }
            }
            catch (Exception e)
            {
                strIngredients = "No Ingredients Provided";
            }
            finally
            {
                itemStatistics.Text = strIngredients;
            }
        }
Esempio n. 2
0
        // This is inherited from IActivityResponse.
        // Called from httpPost once the http request has finished.
        public void proccessFinish(ObservableCollection <tescoApiJson> jsonList)
        {
            // Try exists incase there is a problem with the data from the http response.
            // Needs to have more detailed information. But at the moment allows the code to
            // contiune to execute even if there is an error
            if (Confirmed != true)
            {
                if (jsonList != null)
                {
                    apiJson = jsonList[0];
                    if (apiJson.flags["dataReturned"] == "true" || apiJson.flags == null)
                    {
                        string strDescription = AddSpacesToSentence(apiJson.items[0].description);
                        string strGTIN        = AddSpacesToSentence(apiJson.items[0].gtin);

                        statusMessage.Text = strDescription;
                        barcodeValue.Text  = strGTIN;
                    }
                    else if (apiJson.flags["removed"] == "true")
                    {
                        barcodeValue.Text = "Data Removed";
                        return;
                    }
                }
                else
                {
                    statusMessage.Text = "Retrieval From Server Uncessfull";
                }

                btnReadBarcode.Visibility = ViewStates.Gone;
                btnAddItem.Visibility     = ViewStates.Gone;
                btnRemoveItem.Visibility  = ViewStates.Gone;
                btnConfirm.Visibility     = ViewStates.Visible;
                btnDelete.Visibility      = ViewStates.Visible;
            }
            httpPost.Cancel(true);
            httpPost.Dispose();
        }