示例#1
0
        public static void Create(Restaurant restaurant)
        {
            RestaurantService rs    = new RestaurantService();
            tblOrder          order = new tblOrder();

            order.MenuItem = restaurant.MenuItem;
            order.Date     = restaurant.Date;
            rs.AddOrder(order);
        }
示例#2
0
        public static void Update(int id, Restaurant restaurant)
        {
            RestaurantService rs    = new RestaurantService();
            tblOrder          order = new tblOrder();

            order.OrderID  = id;
            order.MenuItem = restaurant.MenuItem;
            order.Date     = restaurant.Date;
            rs.EditOrder(order);
        }
 public void DeleteOrder(int orderId)
 {
     try
     {
         using (RestaurantEntities context = new RestaurantEntities())
         {
             tblOrder orderToDelete = (from o in context.tblOrders where o.OrderID == orderId select o).First();
             context.tblOrders.Remove(orderToDelete);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
     }
 }
 public tblOrder EditOrder(tblOrder order)
 {
     try
     {
         using (RestaurantEntities context = new RestaurantEntities())
         {
             tblOrder orderToEdit = (from o in context.tblOrders where o.OrderID == order.OrderID select o).First();
             orderToEdit.Date     = order.Date;
             orderToEdit.MenuItem = order.MenuItem;
             context.SaveChanges();
             return(order);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
        public tblOrder AddOrder(tblOrder order)
        {
            try
            {
                using (RestaurantEntities context = new RestaurantEntities())
                {
                    tblOrder newTblOrder = new tblOrder();
                    newTblOrder.Date     = order.Date;
                    newTblOrder.MenuItem = order.MenuItem;
                    context.tblOrders.Add(newTblOrder);
                    context.SaveChanges();

                    return(order);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(null);
            }
        }