Exemple #1
0
 /// <summary>
 /// This method changes order status to rejected and saves changes to database.
 /// </summary>
 /// <param name="order"></param>
 public void RejectOrder(vwOrder order)
 {
     try
     {
         using (PizzeriaEntities context = new PizzeriaEntities())
         {
             tblOrder orderToReject = context.tblOrders.Where(x => x.OrderID == order.OrderID).FirstOrDefault();
             orderToReject.OrderStatus = "rejected";
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
     }
 }
Exemple #2
0
 /// <summary>
 /// This method changes time of order and saves changes to database.
 /// </summary>
 /// <param name="order">Order.</param>
 public void ConfirmOrder(vwOrder order)
 {
     try
     {
         using (PizzeriaEntities context = new PizzeriaEntities())
         {
             tblOrder orderToEdit = context.tblOrders.Where(x => x.OrderID == order.OrderID).FirstOrDefault();
             orderToEdit.DateAndTimeOfOrder = DateTime.Now;
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
     }
 }
 /// <summary>
 /// This method changes order status to approved and saves changes to database.
 /// </summary>
 /// <param name="order">Order to be approved.</param>
 /// <returns>True if order is approved, false if not.</returns>
 public bool ApproveOrder(vwOrder order)
 {
     try
     {
         using (PizzeriaEntities context = new PizzeriaEntities())
         {
             tblOrder orderToApprove = context.tblOrders.Where(x => x.OrderID == order.OrderID).FirstOrDefault();
             orderToApprove.OrderStatus = "approved";
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }
Exemple #4
0
 /// <summary>
 /// This method adds ordered item to DbSet and saves changes to database.
 /// </summary>
 /// <param name="menuItem">Item from menu.</param>
 /// <param name="order">Which order to add item.</param>
 /// <param name="quantity">Quatity of item.</param>
 public void AddOrderItem(vwMenu menuItem, vwOrder order, int quantity)
 {
     try
     {
         using (PizzeriaEntities context = new PizzeriaEntities())
         {
             tblOrderItem itemToAdd = new tblOrderItem
             {
                 FoodID   = menuItem.FoodID,
                 Quantity = quantity,
                 OrderID  = order.OrderID
             };
             context.tblOrderItems.Add(itemToAdd);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
     }
 }