示例#1
0
        public Order(int numberofpizzas, HashSet <string> toppings, User user, int location, PizzaPie pizza)
        {
            if (numberofpizzas <= 0 || numberofpizzas > 12)
            {
                throw new ArgumentException("Number of pizzas ordered is wrong");
            }

            List <string> ListOfToppings = new List <string> {
                "pepperoni", "sausage", "chicken", "ham", "bbqchicken", "onion", "pepper", "pineapple"
            };

            foreach (var top in toppings)
            {
                if (!ListOfToppings.Contains(top))
                {
                    toppings.Remove(top);
                    throw new ArgumentException($"{top} is not a valid topping");
                }
            }

            HowManyPizzas = numberofpizzas;
            Toppings      = toppings;
            User          = user.First + user.Last;
            Location      = location;
            Pizza         = pizza;
        }
示例#2
0
 public static Data.PizzaPie Map(PizzaPie pizza) => new Data.PizzaPie
 {
     Id         = pizza.ID,
     OrderId    = pizza.OrderID,
     Pepper     = pizza.ToppingsDict["pepper"],
     Onion      = pizza.ToppingsDict["onion"],
     Pineapple  = pizza.ToppingsDict["pineapple"],
     Ham        = pizza.ToppingsDict["ham"],
     Chicken    = pizza.ToppingsDict["chicken"],
     Sausage    = pizza.ToppingsDict["sausage"],
     Bbqchicken = pizza.ToppingsDict["bbqchicken"],
     Pepperoni  = pizza.ToppingsDict["pepperoni"]
 };
示例#3
0
 public void AddPizzaToOrder(PizzaPie pizza)
 {
     Pizza = pizza;
 }