Beispiel #1
0
 internal bool IsExistingMeal(int mealID)
 {
     using (var context = new PizzaRestaurantEntities())
     {
         return(context.tblMeals.Any(e => e.MealID == mealID));
     }
 }
Beispiel #2
0
 internal bool IsExistingOrder(int orderID)
 {
     using (var context = new PizzaRestaurantEntities())
     {
         return(context.tblOrders.Any(e => e.OrderID == orderID));
     }
 }
Beispiel #3
0
 internal void AddNewOrder(tblOrder newOrder)
 {
     using (var conn = new PizzaRestaurantEntities())
     {
         conn.tblOrders.Add(newOrder);
         conn.SaveChanges();
     }
 }
Beispiel #4
0
        internal void UpdateOrder(tblOrder orderToUpdate)
        {
            using (var context = new PizzaRestaurantEntities())
            {
                context.tblOrders.First(e => e.OrderID == orderToUpdate.OrderID).IsApproved = orderToUpdate.IsApproved;

                context.SaveChanges();
            }
        }
Beispiel #5
0
 internal List <tblOrder> LoadOrders()
 {
     using (var conn = new PizzaRestaurantEntities())
     {
         var orders = new List <tblOrder>();
         if (conn.tblOrders.Any())
         {
             return(conn.tblOrders.ToList());
         }
         return(orders);
     }
 }
Beispiel #6
0
 internal void DeleteOrderedMeal(tblMealOrder mealOrder)
 {
     using (var context = new PizzaRestaurantEntities())
     {
         var orderToRemove = context.tblMealOrders.FirstOrDefault(e => e.MealOrderID == mealOrder.MealOrderID);
         if (orderToRemove != null)
         {
             context.tblMealOrders.Remove(orderToRemove);
             context.SaveChanges();
         }
     }
 }
Beispiel #7
0
 internal List <string> LoadPersonalNumbers()
 {
     using (var context = new PizzaRestaurantEntities())
     {
         var personalNumbers = new List <string>();
         if (context.tblOrders.Any())
         {
             foreach (var item in context.tblOrders)
             {
                 personalNumbers.Add(item.OrdererPersonalNo);
             }
             return(personalNumbers);
         }
         return(personalNumbers);
     }
 }
Beispiel #8
0
        internal List <tblOrder> LoadOrders(string ordererPersonalNo)
        {
            using (var context = new PizzaRestaurantEntities())
            {
                var orders = new List <tblOrder>();

                if (context.tblOrders.Any(x => x.OrdererPersonalNo == ordererPersonalNo))
                {
                    foreach (var item in context.tblOrders.Where(x => x.OrdererPersonalNo == ordererPersonalNo))
                    {
                        orders.Add(item);
                    }
                    return(orders);
                }
                return(orders);
            }
        }
Beispiel #9
0
        internal List <tblOrder> LoadAllOrders()
        {
            using (var context = new PizzaRestaurantEntities())
            {
                var orders = new List <tblOrder>();

                if (context.tblOrders.Any())
                {
                    foreach (var item in context.tblOrders)
                    {
                        orders.Add(item);
                    }
                    return(orders);
                }
                return(orders);
            }
        }
Beispiel #10
0
        internal List <tblMeal> LoadMeals()
        {
            using (var context = new PizzaRestaurantEntities())
            {
                var meals = new List <tblMeal>();

                if (context.tblMeals.Any())
                {
                    foreach (var item in context.tblMeals)
                    {
                        meals.Add(item);
                    }
                    return(meals);
                }
                return(meals);
            }
        }
Beispiel #11
0
        internal List <tblMealOrder> LoadOrderedMeals(int orderID)
        {
            using (var conn = new PizzaRestaurantEntities())
            {
                var orderedMeals = new List <tblMealOrder>();
                if (conn.tblOrders.Any(x => x.OrderID == orderID))
                {
                    foreach (var item in conn.tblMealOrders.Where(x => x.OrderID == orderID))
                    {
                        orderedMeals.Add(item);
                    }
                    return(orderedMeals);
                }

                return(orderedMeals);
            }
        }