Ejemplo n.º 1
0
        async void OnIngredientDeleteItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            Ingrediente ing;

            if (e.SelectedItem != null)
            {
                ing = e.SelectedItem as Ingrediente;

                // verificam daca utilizatorul doreste sa stearga ingredientul

                string alert = await ApiProcessor.LoadTranslation("Attention!");

                string message = await ApiProcessor.LoadTranslation("Are you sure you want to erase " + ing.StrIngredient + " ?");

                string action_yes = await ApiProcessor.LoadTranslation("Yes");

                string action_no = await ApiProcessor.LoadTranslation("No");

                var action = await DisplayAlert(alert, message, action_yes, action_no);

                if (action)
                {
                    App.listaIngredienteFrigider.Remove(ing);
                    idMax = App.listaIngredienteFrigider.Count;

                    // resetam cache-ul retetelor
                    RecipesPage.InitialiseRecipesCache();

                    // dupa ce stergem un ingredient vom da "refresh" la informatiile de pe pagina
                    ShowPageData(idStart, pasId);
                }
            }
        }
Ejemplo n.º 2
0
        async void OnIngredientAddItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            Ingrediente ing;

            if (e.SelectedItem != null)
            {
                ing = e.SelectedItem as Ingrediente;

                // daca nu mai exista ingredientul, cautam ingredientul respectiv
                // si il adaugam in cache-ul curent al frigiderului
                // daca mai exista, afisam un mesaj de eroare
                if (!App.listaIngredienteFrigider.Contains(ing))
                {
                    App.listaIngredienteFrigider.Add(ing);

                    // resetam cache-ul retetelor
                    RecipesPage.InitialiseRecipesCache();
                }
                else
                {
                    // intrebam utilizatorul daca doreste sa stearga ingredientul


                    string alert = await ApiProcessor.LoadTranslation("Oops!");

                    string message = await ApiProcessor.LoadTranslation("You already added the ingredient in the fridge. Do you wish to remove " + ing.StrIngredientRo + "?");

                    string action_yes = await ApiProcessor.LoadTranslation("Yes, remove it.");

                    string action_no = await ApiProcessor.LoadTranslation("No, don't remove it.");

                    var action = await DisplayAlert(alert, message, action_yes, action_no);

                    if (action)
                    {
                        App.listaIngredienteFrigider.Remove(ing);
                    }

                    // resetam cache-ul retetelor
                    RecipesPage.InitialiseRecipesCache();
                }

                // change bg color to white after u finished adding/selecting it OR find a way to deselect item
            }
        }
Ejemplo n.º 3
0
        void OnSaveFiltreButtonClicked(object sender, EventArgs e)
        {
            RecipesPage.InitialiseRecipesCache();

            Navigation.PushAsync(new RecipesPage(m_utilizator, m_listaIngrediente, m_listaFiltre_cat, m_listaFiltre_reg));
        }