Ejemplo n.º 1
0
        /// <summary>
        /// Method to update the list of available ingredients
        /// </summary>
        /// <returns></returns>
        public async Task UpdateIngredientLists()
        {
            // Getting all ingredients from the database...
            AllAvailableIngredientsList = await rep.GetAllCondiments();

            // ...and casting it to queryable list
            var IngredientsToChooseFrom = AllAvailableIngredientsList.Cast <BackendHandler.Condiment>().ToList();

            // Goes through the already set ingredients
            CondimentsOnPizza.Cast <BackendHandler.Condiment>().ToList().ForEach(x =>
            {
                // and removing them from the list of available condiments
                for (int i = 0; i < IngredientsToChooseFrom.Count; i++)
                {
                    if (x.CondimentID == IngredientsToChooseFrom[i].CondimentID)
                    {
                        IngredientsToChooseFrom.Remove(IngredientsToChooseFrom[i]);
                    }
                }
            });

            // Updates the list of available ingredients
            AllAvailableIngredientsList = IngredientsToChooseFrom;

            BasePizza.PizzaIngredients = CondimentsOnPizza.Cast <BackendHandler.Condiment>().ToList();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Command to remove a selected ingredient in a list from the pizza
        /// </summary>
        public async Task RemoveIngredientCommand()
        {
            // Removes the selected condiment
            CondimentsOnPizza.Remove(CondimentToRemove);

            // And adds it back to the list of available condiments
            AllAvailableIngredientsList.Cast <BackendHandler.Condiment>().ToList().Add(CondimentToRemove);

            // Updates the lists
            await UpdateIngredientLists();
        }