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();
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#5
0
 private static void Peel(IIngredient ingredient)
 {
     Console.WriteLine("{0} is peeled", ingredient.GetType().Name);
 }
示例#6
0
 private static void Cut(IIngredient ingredient)
 {
     Console.WriteLine("{0} is cut", ingredient.GetType().Name);
 }
示例#7
0
 private void Peel(IIngredient ingredient)
 {
     Console.WriteLine("Peeling {0}", ingredient.GetType().Name);
 }
示例#8
0
 private void Cut(IIngredient ingredient)
 {
     Console.WriteLine("Cutting {0}", ingredient.GetType().Name);
 }
示例#9
0
 public void Add(IIngredient ingredient)
 {
     Console.WriteLine("Adding {0}", ingredient.GetType().Name);
 }
示例#10
0
 private static void Peel(IIngredient ingredient)
 {
     Console.WriteLine("{0} is peeled", ingredient.GetType().Name);
 }
示例#11
0
 private static void Cut(IIngredient ingredient)
 {
     Console.WriteLine("{0} is cut", ingredient.GetType().Name);
 }