Ejemplo n.º 1
0
 public static Location Map(Models.PizzaStore store) => new Location
 {
     LocationName = store.Name,
     Address      = Map(store.Location),
     Inventory    = MapInventory(store.Inventory),
     Orders       = Map(store.OrderHistory)
 };
Ejemplo n.º 2
0
        public static Models.PizzaStore Map(Location store)
        {
            var newStore = new Models.PizzaStore(store.LocationName, Map(store.Inventory), Map(store.Address));

            foreach (var order in store.Orders)
            {
                newStore.OrderHistory.Add(Map(order));
            }
            return(newStore);
        }
Ejemplo n.º 3
0
        //new Models.Order(Map(order.Store), Map(order.Customer), Map(order.Address), Map(order.OrderItems), order.OrderTime);

        public static Models.PizzaStore Map(Location store)
        {
            Models.PizzaStore newStore = null;
            if (store != null)
            {
                newStore    = new Models.PizzaStore(store.LocationName, Map(store.Inventory));
                newStore.Id = store.Id;
                foreach (var order in store.Orders)
                {
                    newStore.OrderHistory.Add(Map(order));
                }
            }

            return(newStore);
        }
Ejemplo n.º 4
0
        public Order(PizzaStore store, Customer cust, Address deliveryAdd, Dictionary <Pizza, int> orderItems, DateTime now)
        {
            Store    = store ?? throw new ArgumentNullException(nameof(store), "Order's store must not be null.");;
            Customer = cust ?? throw new ArgumentNullException(nameof(cust), "Order's customer must not be null.");

            Address = deliveryAdd;                                //null address means carry out

            OrderItems = new Dictionary <Pizza, int>(orderItems); //don't want modifiable order history
            foreach (var pizza in orderItems)                     //total price is the sum of the number of each pizza times its price
            {
                TotalPrice += pizza.Value * pizza.Key.Price;
            }

            OrderTime = now;
        }