Example #1
0
        public void Add_To_Datebase(string data)
        {
            IDishRepository  repoDish   = new DishRepository();
            IOrderRepository repository = new OrderRepository();
            Order            order;
            Dish             dish;
            int tableID = Int32.Parse(char.ToString(data[0]));

            data = data.Remove(0, 2);
            Console.WriteLine(data);
            Console.WriteLine(tableID);
            string[] Dish_Price = data.Split(";");
            foreach (var x in Dish_Price)
            {
                order = new Order();
                dish  = new Dish();
                string[] element = x.Split(",");
                Console.WriteLine(element[1]);
                dish.Name      = element[0];
                dish.DishPrice = Double.Parse(element[1], CultureInfo.InvariantCulture.NumberFormat);
                var ID = repoDish.CheckDish(dish);
                if (ID == 0)
                {
                    order.DishID = repoDish.CreateDish(dish);
                }
                else
                {
                    order.DishID = ID;
                }

                order.TableID   = tableID;
                order.TimeStamp = DateTime.Now.ToString("HH:mm:ss");
                repository.CreateOrder(order);
            }
        }
        private void Add_Dish_Click(object sender, RoutedEventArgs e)
        {
            Dish dish = new Dish()
            {
                Name = DishNameBox.Text, DishPrice = Convert.ToInt32(DishPriceBox.Text)
            };
            IDishRepository repository = new DishRepository();

            repository.CreateDish(dish);
        }