public void AddFoodCustomer(FoodCustomer customer) { try { using (FoodOrderAppBaseEntities context = new FoodOrderAppBaseEntities()) { context.FoodCustomers.Add(customer); context.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Exception " + ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void DeleteFoodCustomer(int customerID) { try { using (FoodOrderAppBaseEntities context = new FoodOrderAppBaseEntities()) { FoodCustomer customer = (from c in context.FoodCustomers where c.CustomerID == customerID select c).FirstOrDefault(); context.FoodCustomers.Remove(customer); context.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Exception " + ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void UpdateFoodOrder(FoodOrder updatedOrder) { try { using (FoodOrderAppBaseEntities context = new FoodOrderAppBaseEntities()) { FoodOrder order = (from o in context.FoodOrders where o.OrderID == updatedOrder.OrderID select o).FirstOrDefault(); order.StatusOfOrder = updatedOrder.StatusOfOrder; context.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Exception " + ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }