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; }
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"] };
public void AddPizzaToOrder(PizzaPie pizza) { Pizza = pizza; }