Example #1
0
 /// <summary>
 /// Saves the Order in database
 /// </summary>
 private void SaveExecute()
 {
     try
     {
         tblOrder order = new tblOrder();
         order.Price = Price;
         order.State = "Waiting";
         using (PizzaRestourantEntities db = new PizzaRestourantEntities())
         {
             tblGuest guest = db.tblGuests.Where(x => x.Username == "2201996800109").FirstOrDefault();
             order.FKGuest = guest.Id;
             DateTime dateTime = DateTime.Now;
             order.CreatedDate = dateTime.Date;
             order.CreatedTime = dateTime.TimeOfDay;
             db.tblOrders.Add(order);
             db.SaveChanges();
         }
         MessageBox.Show($"Ordered Successfully! Order Status: {order.State}");
         main.Close();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
     }
 }
 /// <summary>
 /// Method for canceling order command execution
 /// </summary>
 public void CancelOrderExecute()
 {
     try
     {
         orderService.CancelOrder(Ordered.OrderId);
         OrderList = oiService.GetAllOrderedItems(username);
         guestView.Close();
         LoginView newLogin = new LoginView();
         newLogin.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
 /// <summary>
 /// This method invokes method for deleting order.
 /// </summary>
 public void CancelOrderExecute()
 {
     try
     {
         MessageBoxResult result = MessageBox.Show("Are you sure you want to cancel the order?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             bool isCanceled = newOrder.CancelOrder(Ordered.OrderID);
             if (isCanceled == true)
             {
                 MessageBox.Show("Order is canceled.", "Notification", MessageBoxButton.OK);
             }
             else
             {
                 MessageBox.Show("Order cannot be canceled.", "Notification", MessageBoxButton.OK);
             }
             OrderList = orderItems.GetOrderedItems(username);
             guestView.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Example #4
0
 private void CloseExecute()
 {
     try
     {
         guestView.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
 /// <summary>
 /// This method invokes method for deleteing order.
 /// </summary>
 public void CancelOrderExecute()
 {
     try
     {
         newOrder.CancelOrder(Ordered.OrderID);
         OrderList = orderItems.GetOrderedItems(username);
         guestView.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }