Example #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);
            }
        }
Example #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);
            }
        }
Example #3
0
        public static List <Servers> GetServers()
        {
            using (var context = new OurRestaurantModel())
            {
                List <Servers> servers = context.Servers.ToList();

                return(servers);
            }
        }
        /// <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);
            }
        }
Example #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);
            }
        }
Example #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);
            }
        }
Example #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);
            }
        }
Example #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);
            }
        }
Example #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);
     }
 }
Example #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);
            }
        }
        /// <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);
            }
        }
Example #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);
            }
        }