Example #1
0
 public async Task<IEnumerable<Drink>> GetDrinkAvailableAsync()
 {
     List<Drink> drinksResult = new List<Drink>();
     var drinks = await db.Drinks.ToListAsync();
     foreach (var d in drinks)
     {
         switch (d.CodDrink)
         {
             case "COFFEE":
                 var c = new Coffee();
                 c.SetPrice(d.Price);
                 drinksResult.Add(c);
                 break;
             case "THE":
                 var t = new The();
                 t.SetPrice(d.Price);
                 drinksResult.Add(t);
                 break;
             case "CAPPUCCINO":
                 var ca = new Cappuccino();
                 ca.SetPrice(d.Price);
                 drinksResult.Add(ca);
                 break;
         }
     }
     return drinksResult;
 }