Exemplo n.º 1
0
        private List <Pizza> GetPizzas()
        {
            List <Pizza> pizzas = new List <Pizza>();
            int          randP  = 1;
            int          randI  = 1;

            for (int i = 1; i < 10; i++)
            {
                randP = this.GetRandPate();
                Pizza randPizza = new Pizza
                {
                    Id   = i,
                    Nom  = String.Format("Pizza n°{0}", i),
                    Pate = ListePates.FirstOrDefault(x => x.Id == randP)
                };

                randPizza.Ingredients = new List <Ingredient>();
                Ingredient ingredientAdded = new Ingredient();
                int        limit           = rand.Next(3, 10);
                for (int j = 0; j < limit; j++)
                {
                    randI = this.GetRandIngredient();
                    Ingredient ingredientRandom = ListeIngredients.Where(x => x.Id == randI).First();
                    if (ingredientRandom != ingredientAdded)
                    {
                        randPizza.Ingredients.Add(ingredientRandom);
                        ingredientAdded = ingredientRandom;
                    }
                }
                pizzas.Add(randPizza);
            }
            return(pizzas);
        }
Exemplo n.º 2
0
 private int GetRandPate()
 {
     return(rand.Next(1, ListePates.Count() - 1));
 }