public void VisitIngredients(IIngredient ingredient) { if (ingredient.HealthRating == HealthRating.NotRated || ingredient.Calories == 0) { return; } string padding = ""; if (string.IsNullOrEmpty(ingredient.IngredientName)) { Console.WriteLine("--- Item {0} ---", ingredient.GetType().Name); } else { Console.WriteLine(" --- Ingredient {0} ---", ingredient.IngredientName); padding = " "; } Console.WriteLine(padding + "Health Rating: {0}", ingredient.HealthRating); Console.WriteLine(padding + "Calories: {0}", ingredient.Calories); Console.WriteLine(padding + "Carbs: {0}", ingredient.Carbs); Console.WriteLine(padding + "Protein: {0}", ingredient.Protein); Console.WriteLine(); }
public IBeverage AddIngredient(IIngredient ingredient) { switch (ingredient.GetType().ToString()) { case "Barista.Milk": _milk = ingredient; break; case "Barista.MilkFoam": _milkfoam = ingredient; break; case "Barista.ChocolateSyrup": _chocolatesyrup = ingredient; break; default: Console.WriteLine(ingredient.GetType().ToString()); break; } return(this); }
public void GivenExistingAlternativeIngredientName_WhenAskingToMap_ThenItShouldReturnCorrectIngredient() { // arrange const string name = "Crispy Ham"; IngredientMap ingredientMap = new IngredientMap(); // act IIngredient mappedIngredient = ingredientMap.DomainIngredient(name, new Pizza(), new SpringfieldLocation()); // assert mappedIngredient.Name().ToString().Should().BeEquivalentTo(new CrispyHamName()); mappedIngredient.GetType().Name.Should().Be(nameof(CrispyHam)); }
/// <summary> /// Finds an Ingredient Id /// </summary> public int?FindIngredientId(IIngredient ingredient, int userId) { if (ingredient == null) { throw new ArgumentNullException("ingredient"); } var set = this.Repository.GetSet(ingredient.GetType()) as IQueryable <IIngredient>; var match = set .Where(x => x.Name == ingredient.Name) .Where(x => x.IsActive) .Where(x => (x.IsPublic || (!x.IsPublic && x.CreatedByUserId == userId))) .Select(x => x.IngredientId) .FirstOrDefault(); return(match > 0 ? (int?)match : null); }
private static void Peel(IIngredient ingredient) { Console.WriteLine("{0} is peeled", ingredient.GetType().Name); }
private static void Cut(IIngredient ingredient) { Console.WriteLine("{0} is cut", ingredient.GetType().Name); }
private void Peel(IIngredient ingredient) { Console.WriteLine("Peeling {0}", ingredient.GetType().Name); }
private void Cut(IIngredient ingredient) { Console.WriteLine("Cutting {0}", ingredient.GetType().Name); }
public void Add(IIngredient ingredient) { Console.WriteLine("Adding {0}", ingredient.GetType().Name); }