public async void Sauvegarder_Clicked(System.Object sender, System.EventArgs e)
        {
            // if (isNumeric(EntréeCodeBarre.Text))
            {
                var nutriInfo = await InfoResponseApi.LoadInfo((EntréeCodeBarre.Text));

                SortieApi.Text = $"le classe de nutriment est {nutriInfo}";
            }
        }
예제 #2
0
        async private void Sauvegarder_Clicked(System.Object sender, System.EventArgs e)
        {
            var nutriInfo = await InfoResponseApi.LoadInfo((EntréeCodeBarre.Text));

            if (nutriInfo == null)
            {
                SortieApi.Text            = "Barcode Invalid";
                SortieApi.TextColor       = Color.Red;
                SortieApi.BackgroundColor = Color.White;
            }
            else
            {
                if (nutriInfo.Nutrition_grades == null)
                {
                    SortieApi.Text            = "The product is not listed";
                    SortieApi.BackgroundColor = Color.Black;
                    SortieApi.TextColor       = Color.White;
                }

                else
                {
                    string nutri = nutriInfo.Nutrition_grades;

                    SortieApi.TextColor = Color.White;
                    //  SortieApi.Text = $"The nutritional score of the product is { nutri.ToUpper()}\n The nova score of the product is {nova.ToUpper()}";
                    switch (nutri)
                    {
                    case ("a"):
                        SortieApi.BackgroundColor = Color.FromHex("#038141");

                        break;

                    case ("b"):
                        SortieApi.BackgroundColor = Color.FromHex("#85BB2F");
                        break;

                    case ("c"):
                        SortieApi.BackgroundColor = Color.FromHex("#FECB02");
                        break;

                    case ("d"):
                        SortieApi.BackgroundColor = Color.FromHex("#EE8100");
                        break;

                    case ("e"):
                        SortieApi.BackgroundColor = Color.FromHex("#E63E11");
                        break;
                    }
                }
            }
        }
        async private void Sauvegarder_Clicked(System.Object sender, System.EventArgs e)
        {
            int Desc;

            if (!InternetGetConnectedState(out Desc, 0))
            {
                SortieApi.Text = "You are not connected to the Internet";
            }
            else
            {
                var col = Database.db.GetCollection <FrigoBaseDeDonnée>("FrigoBaseDeDonnée");
                if (EntréeCodeBarre.Text == null || EntréeCodeBarre.Text == "")
                {
                    if (SiPasCodeBarre.Text != null)
                    {
                        FrigoBaseDeDonnée.InsertProduct(null, SiPasCodeBarre.Text, -1, -1, -1, null, null, null, -1, null, peremption.Date, null, null);

                        create();
                    }
                }
                else
                {
                    var nutriInfo = await InfoResponseApi.LoadInfo((EntréeCodeBarre.Text));

                    if (nutriInfo == null)
                    {
                        SortieApi.Text = "Invalid Barcode";
                    }
                    else
                    {
                        if (nutriInfo.Ingredients_text != null)
                        {
                            FrigoBaseDeDonnée.InsertProduct(EntréeCodeBarre.Text, nutriInfo.Product_name_fr, nutriInfo.Nutriments.Sugars_100g, nutriInfo.Nutriments.Salt_100g, nutriInfo.Nutriments.Fat_100g, nutriInfo.Nutrient_levels.Salt, nutriInfo.Nutrient_levels.Sugars, nutriInfo.Nutrient_levels.Fat, nutriInfo.Nutriments.Proteins_100g, nutriInfo.Ingredients_text, peremption.Date, nutriInfo.Nutrition_grades, nutriInfo.Quantity);
                            SortieApi.Text = "The product has been added with succes to your pantry";

                            create();
                        }

                        else
                        {
                            SortieApi.Text = "Invalid Barcode";
                        }
                    }
                }
            }
        }