예제 #1
0
        /// <summary>
        /// Returns all products from the database
        /// </summary>
        /// <returns></returns>
        public static List <Products> GetProducts()
        {
            using (var context = new OurRestaurantModel())
            {
                List <Products> products = context.Products.ToList();

                return(products);
            }
        }
예제 #2
0
        /// <summary>
        /// Pulls all transactions from the database and returns them in a list.
        /// </summary>
        /// <returns></returns>
        public static List <Transactions> GetTransactions()
        {
            using (var context = new OurRestaurantModel())
            {
                List <Transactions> transactions = context.Transactions.ToList();

                return(transactions);
            }
        }
예제 #3
0
        public static List <Servers> GetServers()
        {
            using (var context = new OurRestaurantModel())
            {
                List <Servers> servers = context.Servers.ToList();

                return(servers);
            }
        }
예제 #4
0
        /// <summary>
        /// Gets all payments from the database
        /// </summary>
        /// <returns></returns>
        public static List <PaymentInfo> GetPayments()
        {
            using (var context = new OurRestaurantModel())
            {
                List <PaymentInfo> payments = context.PaymentInfo.ToList();

                return(payments);
            }
        }
예제 #5
0
        /// <summary>
        /// Adds new product object to database
        /// </summary>
        /// <param name="newProduct"></param>
        /// <returns></returns>
        public static Products AddProduct(Products newProduct)
        {
            using (var context = new OurRestaurantModel())
            {
                context.Products.Add(newProduct);
                context.SaveChanges();

                return(newProduct);
            }
        }
예제 #6
0
        public static List <Products> GetDesserts()
        {
            using (var context = new OurRestaurantModel())
            {
                List <Products> desserts =
                    new List <Products>(context.Products.OfType <Desserts>().ToList());

                return(desserts);
            }
        }
예제 #7
0
        public static List <Products> GetEntrees()
        {
            using (var context = new OurRestaurantModel())
            {
                List <Products> entrees =
                    new List <Products>(context.Products.OfType <Entrees>().ToList());

                return(entrees);
            }
        }
예제 #8
0
        public static List <Products> GetBeverages()
        {
            using (var context = new OurRestaurantModel())
            {
                List <Products> beverages =
                    new List <Products>(context.Products.OfType <Beverages>().ToList());

                return(beverages);
            }
        }
예제 #9
0
 /// <summary>
 /// Deletes a server from the database
 /// </summary>
 /// <param name="server"></param>
 public static bool DeleteServer(Servers server)
 {
     using (var context = new OurRestaurantModel())
     {
         context.Servers.Add(server);
         context.Entry(server).State = EntityState.Deleted;
         int rowsAffected = context.SaveChanges();
         return(rowsAffected > 0);
     }
 }
예제 #10
0
        /// <summary>
        /// Adds new server to database
        /// </summary>
        /// <param name="newServer"></param>
        public static Servers AddServer(Servers newServer)
        {
            using (var context = new OurRestaurantModel())
            {
                context.Servers.Add(newServer);
                context.SaveChanges();

                return(newServer);
            }
        }
예제 #11
0
        /// <summary>
        /// Adds a new payment to the database
        /// </summary>
        /// <param name="newPayment"></param>
        /// <returns></returns>
        public static PaymentInfo AddPayment(PaymentInfo newPayment)
        {
            using (var context = new OurRestaurantModel())
            {
                context.PaymentInfo.Add(newPayment);
                context.SaveChanges();

                return(newPayment);
            }
        }
예제 #12
0
        /// <summary>
        /// Adds an individual transaction to the database
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public static Transactions AddTransaction(Transactions order)
        {
            using (var context = new OurRestaurantModel())
            {
                /////////////////////////////////////
                // Need to keep for tracking items ALREADY IN database
                // Without this, items will be re-added to the database
                // with identical rows but for the ID column
                // DO NOT TAKE OUT
                foreach (var item in order.Products)
                {
                    context.Entry(item).State = EntityState.Unchanged;
                }
                context.Entry(order.Server).State = EntityState.Unchanged;
                /////////////////////////////////////

                context.Transactions.Add(order);
                context.SaveChanges();

                return(order);
            }
        }