コード例 #1
0
        public EditOrder(EditOrderViewModel edit)
        {
            List <Order> order = db.Orders.Where(m => m.TableNo == edit.EditTableId).ToList();
            Mappings     map   = new Mappings();

            //Delete Order
            if (edit.OrderDeletion == true)
            {
                ManageRestaurant manage = new ManageRestaurant();
                foreach (Order index in order)
                {
                    db.Orders.Remove(index);
                    db.SaveChanges();
                }
                manage.TableStatus((int)edit.EditTableId, false);
            }
            //Update Order
            else
            {
                for (int index = 0; index < edit.EditedQuantity.Count(); index++)
                {
                    order[index].Quantity        = edit.EditedQuantity[index];
                    db.Entry(order[index]).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
        }
コード例 #2
0
        public Order AddOrder(OrderViewModel orderView)
        {
            Order order = Mapper.Map <OrderViewModel, Order>(orderView);

            db.Orders.Add(order);
            db.SaveChanges();
            return(order);
        }
コード例 #3
0
        //usuwanie danego wiersza
        public bool delete_row(string name_of_table, string name_of_key, string name_of_column)
        {
            try
            {
                string com = "Delete from " + name_of_table + " where " + name_of_column + " = " + name_of_key;
                using (var context = new RestaurantEntities3())
                {
                    using (var dbContextTransaction = context.Database.BeginTransaction())
                    {
                        try
                        {
                            context.Database.ExecuteSqlCommand(com);
                            context.SaveChanges();

                            dbContextTransaction.Commit();
                        }
                        catch (Exception)
                        {
                            dbContextTransaction.Rollback();
                        }
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
コード例 #4
0
        /// <summary>
        /// OrderData storing adds order into database checks for duplicate orders and combine them into single order and also change the status of the table.
        /// </summary>
        public OrderDataStoring(List <OrderViewModel> orderData)
        {
            Mappings map   = new Mappings();
            int      count = orderData.Count;

            //For Loop to combine Duplicate orders
            for (int index = 0; index < count - 1; index++)
            {
                //loop to check for duplicate values.
                for (int innerIndex = index + 1; innerIndex < count; innerIndex++)
                {
                    if (orderData[index].OrderId == orderData[innerIndex].OrderId)
                    {
                        orderData[index].Quantity = orderData[index].Quantity + orderData[innerIndex].Quantity;
                        count--;
                        orderData.RemoveAt(innerIndex);
                    }
                }
            }
            //store the order in database
            foreach (OrderViewModel index in orderData)
            {
                selectedTable        = index.TableNo;
                orderModel.TableNo   = index.TableNo;
                orderModel.OrderId   = index.OrderId;
                orderModel.Quantity  = index.Quantity;
                orderModel.OrderTime = index.OrderTime;
                db.Orders.Add(orderModel);
                db.SaveChanges();
            }
            //To toggle the status of table
            ManageRestaurant manage = new ManageRestaurant();
            bool             check  = manage.TableStatus(selectedTable, true);
        }
コード例 #5
0
        /// <summary>
        /// Add Menu Method adds new menu to the MenuTable
        /// It checks the menu Table if the inputed item is already present if present it returns false
        /// if not then updates the database.
        /// </summary>
        /// <param name="menu"></param>
        /// <returns></returns>
        public bool AddMenu(MenuViewModel menu)
        {
            Menu menuConfig = db.Menus.Where(x => x.MenuId == menu.MenuId).FirstOrDefault();

            if (menuConfig != null)
            {
                return(false);
            }
            menuConfig = Mapper.Map <MenuViewModel, Menu>(menu);
            db.Menus.Add(menuConfig);
            db.SaveChanges();
            return(true);
        }
コード例 #6
0
        /// <summary>
        ///Bill Information such as Customer Name, Mob No, Bill Id, amount Paid etc is getting stored on database and Clearing Order Data from Database
        ///and Changing the table status to available
        /// </summary>
        /// <param name="bill"></param>
        public BillStoring(CustomerBillStoringViewModel bill)
        {
            Mappings map = new Mappings();

            map.BillStoring(bill.Bill);
            map.CustomerStoring(bill.Customer);
            int          tableNo   = (bill.Bill.TableNo);
            List <Order> orderList = db.Orders.Where(a => a.TableNo == tableNo).ToList();

            foreach (Order index in orderList)
            {
                db.Orders.Remove(index);
                db.SaveChanges();
            }
            ManageRestaurant manage = new ManageRestaurant();
            bool             check  = manage.TableStatus(bill.Bill.TableNo, false);
        }
コード例 #7
0
        public bool add_row(string name_of_table, string val1, string col1, string val2, string col2,
                            string val3, string col3, string val4, string col4, string val5, string col5, string val6, string col6, string val7, string col7, byte[] passWord, string col8)
        {
            var obj = new Object();

            try
            {
                string com;
                string tmp = "";

                com = "Insert into " + name_of_table + "(";
                if (val1 != "")
                {
                    com += col1;
                    if (val2 != "")
                    {
                        com += "," + col2;
                        if (val3 != "")
                        {
                            com += "," + col3;
                            if (val4 != "")
                            {
                                com += "," + col4;
                                if (val5 != "")
                                {
                                    com += "," + col5;
                                    if (val6 != "")
                                    {
                                        com += "," + col6;
                                        if (val7 != "")
                                        {
                                            com += "," + col7;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                com += ") values (";
                if (val1 != "")
                {
                    com += "'" + val1 + "'";
                    if (val2 != "")
                    {
                        com += "," + "'" + val2 + "'";
                        if (val3 != "")
                        {
                            if (val3.Contains("to_date"))
                            {
                                com += "," + "" + val3 + "";
                            }
                            else
                            {
                                com += "," + "'" + val3 + "'";
                            }
                            if (val4 != "")
                            {
                                com += "," + "'" + val4 + "'";
                                if (val5 != "")
                                {
                                    com += "," + "'" + val5 + "'";
                                    if (val6 != "")
                                    {
                                        com += "," + "'" + val6 + "'";
                                        if (val7 != "")
                                        {
                                            com += "," + "'" + val7 + "'";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                com += ")";
                using (var context = new RestaurantEntities3())
                {
                    using (var dbContextTransaction = context.Database.BeginTransaction())
                    {
                        try
                        {
                            context.Database.ExecuteSqlCommand(com);
                            context.SaveChanges();

                            dbContextTransaction.Commit();
                        }
                        catch (Exception)
                        {
                            dbContextTransaction.Rollback();
                        }
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
コード例 #8
0
        //aktualizacja po edit
        public bool update_row(string name_of_table, string name_of_key, string col_key, string val1, string col1, string val2, string col2,
                               string val3, string col3, string val4, string col4, string val5, string col5, string val6, string col6, string val7, string col7)
        {
            var    obj = new Object();
            string tmp = "";
            string com;

            if (name_of_table == "ZAMOWIENIE")
            {
                com = "Update " + name_of_table;

                com += " set  " + col1 + "=" + "'" + val1 + "'";
                if (val2 != "")
                {
                    com += "," + col2 + "=" + "'" + val2 + "'";
                }
                if (val3 != "")
                {
                    com += "," + col3 + "=" + "'" + val3 + "'";
                }

                com += "," + col4 + "=" + "'" + val4 + "'";

                com += "," + col5 + "=" + "'" + val5 + "'";
            }
            else
            {
                com = "Update " + name_of_table;
                if (val1 != "")
                {
                    com += " set  " + col1 + "=" + "'" + val1 + "'";
                    if (val2 != "")
                    {
                        com += "," + col2 + "=" + "'" + val2 + "'";
                        if (val3 != "")
                        {
                            com += "," + col3 + "=" + "'" + val3 + "'";
                            if (val4 != "")
                            {
                                com += "," + col4 + "=" + "'" + val4 + "'";
                                if (val5 != "")
                                {
                                    com += "," + col5 + "=" + "'" + val5 + "'";
                                    if (val6 != "")
                                    {
                                        com += "," + col6 + "=" + "'" + val6 + "'";
                                        if (val7 != "")
                                        {
                                            com += "," + col7 + "=" + "'" + tmp + "'";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            com += " where " + col_key + "=" + name_of_key;
            try
            {
                using (var context = new RestaurantEntities3())
                {
                    using (var dbContextTransaction = context.Database.BeginTransaction())
                    {
                        try
                        {
                            context.Database.ExecuteSqlCommand(com);
                            context.SaveChanges();

                            dbContextTransaction.Commit();
                        }
                        catch (Exception)
                        {
                            dbContextTransaction.Rollback();
                        }
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }