Ejemplo n.º 1
0
 public Order(Customer customer, AStore store, List <APizza> pizzas, DateTime dateTime)
 {
     Customer = customer;
     Store    = store;
     Pizzas   = pizzas;
     DateTime = dateTime;
 }
 private bool CanChangeStore(AStore store)
 {
     if (LastStore == null)
     {
         LastStore = store;
         return(true);
     }
     else
     {
         if (LastStore.Name != store.Name)
         {
             if (DateTime.UtcNow.Subtract(LastTimeOrdered).TotalHours > 24) //If it has been 24 hours(1day) since last order
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(true);
         }
     }
 }
 public bool AddStoreToCurrentOrder(AStore store)
 {
     if (HasOrderedStoreIn24Hrs(store))
     {
         return(false);
     }
     CurrentOrder.Store = store;
     return(true);
 }
Ejemplo n.º 4
0
        public bool HasOrderedStoreIn24Hrs(AStore store)
        {
            var now        = DateTime.Now;
            var oneDaySpan = new TimeSpan(1, 0, 0, 0);

            foreach (var order in FinishedOrders)
            {
                if (order.Store.GetType() == store.GetType() && Math.Abs(now.Subtract(order.date).TotalHours) < oneDaySpan.TotalHours)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
 public void AddToppings(AStore store)
 {
     foreach (string s in _presetToppings)
     {
         foreach (Topping t in store.ToppingsList)
         {
             if (t.Name == s)
             {
                 Toppings.Add(t);
                 break;
             }
         }
     }
 }
        public bool HasOrderedStoreIn24Hrs(AStore store)
        {
            var now        = DateTime.Now;
            var oneDaySpan = new TimeSpan(1, 0, 0, 0);

            for (int i = 0; i < FinishedOrders.Count; i++)
            {
                // Console.WriteLine("order: " + FinishedOrders[i]);
                if (FinishedOrders[i].Store.Name == store.Name && Math.Abs(now.Subtract(FinishedOrders[i].date).TotalHours) < oneDaySpan.TotalHours)
                {
                    // Console.WriteLine("Sorry, You cannot order from the same store twice within 24 hours");
                    return(true);
                }
            }
            return(false);
        }
 public bool StartOrderCheck(AStore store)
 {
     if (!CanChangeStore(store))
     {
         Console.WriteLine("Ordered from another store in last 24 hours. Can't order again. (Previous store: {0} - Time Remaining: {1})", LastStore, TimeRemaining(24));
         return(false);
     }
     if (!CanOrder())
     {
         Console.WriteLine("Ordered in last 2 hours. Can't order again. (Time Remaining: {0})", TimeRemaining(2));
         return(false);
     }
     LastStore       = store;
     LastTimeOrdered = DateTime.UtcNow;
     return(true);
 }
Ejemplo n.º 8
0
 public Order(Customer c, AStore s) : this()
 {
     Name      = c.Name;
     StoreName = s.Name;
 }
Ejemplo n.º 9
0
 public Order()
 {
     OrderCustomer = new Customer();
     PizzaStore    = new AStore();
     MyPizzas      = new List <APizza>();
 }
Ejemplo n.º 10
0
 public Order(Customer customer, AStore store)
 {
     OrderCustomer = customer;
     PizzaStore    = store;
     MyPizzas      = new List <APizza>();
 }