Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
            }
        }