Example #1
0
 internal static void updateStockUsingFileData(StockContainer container, string[] dataLines)
 {
     foreach (string line in dataLines)
     {
         string[] data = line.Split(',');
         Product  prod = new Product(Int32.Parse(data[0]), data[1], Int32.Parse(data[2]), data[3], Double.Parse(data[4]));
         container.AddProductToList(prod);
     }
 }
Example #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        // You could do validation here and display an error message if something is not right.
        // For simplicity I am assuming the data comes from a set of textboxes.
        if (!PageIsValid())
        {
            return;
        }

        StockContainer _context = new StockContainer();
        Order          newOrder = Order.CreateOrder(txtOrderDate.Text, txtQuantity.Text, txtNeededBy.Text, id);

        _context.Orders.AddObject(newOrder);
        _context.SaveChanges();
        // Add your redirect logic here.
    }
Example #3
0
        internal static void updateMenuUsingFileData(Menu menu, string[] dataLines, StockContainer container)
        {
            if (dataLines == null)
            {
                return;
            }
            foreach (string line in dataLines)
            {
                string[] data = line.Split(',');


                List <Product> prod = Utility.BuildAddItemList(data[2], container);
                Item           item = new Item(Int32.Parse(data[0]), data[1], prod);

                menu.AddItemToMenu(item);
            }
        }
Example #4
0
        internal static List <Product> BuildAddItemList(string chosenId, StockContainer container)
        {
            List <Product> productAddList = new List <Product>();

            string[] splitId  = chosenId.Split(' ');
            string[] uniqueId = splitId.Distinct().ToArray();
            foreach (string productId in uniqueId)
            {
                foreach (Product prod in container.ProductList)
                {
                    int integerId = Int32.Parse(productId);
                    if (integerId == prod.id)
                    {
                        productAddList.Add(prod);
                    }
                }
            }
            return(productAddList);
        }
Example #5
0
        static void Main(string[] args)
        {
            StockContainer container     = new StockContainer();
            Menu           menu          = new Menu();
            OrderList      orderList     = new OrderList();
            string         stockFilePath = "C:/Users/Domantas/source/repos/Visma/Visma_Restaurant/Stock.txt";
            string         menuFilePath  = "C:/Users/Domantas/source/repos/Visma/Visma_Restaurant/Menu.txt";
            string         orderFilePath = "C:/Users/Domantas/source/repos/Visma/Visma_Restaurant/Orders.txt";

            Services.File.updateStockUsingFileData(container, Services.File.readFile(stockFilePath));
            Services.File.updateMenuUsingFileData(menu, Services.File.readFile(menuFilePath), container);
            Services.File.updateOrdersUsingFileData(orderList, Services.File.readFile(orderFilePath), menu);


            while (true)
            {
                Console.WriteLine("________________________________________________");
                Console.WriteLine("Choose an operation:\n 1. Show product list \n 2. Add new product \n 3. Restock products \n 4. Update existing product \n 5. Remove product \n 6. Print Menu \n 7. Add menu items \n 8. Update menu item info \n 9. Delete menu item \n 10. New Order \n 11. Check orders \n 0. End program\n");
                int caseSwitch = Int32.Parse(Console.ReadLine());


                switch (caseSwitch)
                {
                case 1:
                    Cases.PrintProductList(container);
                    break;

                case 2:
                    Cases.AddNewProduct(container);
                    break;

                case 3:
                    Cases.RestockProduct(container);
                    break;

                case 4:
                    Cases.UpdateExistingProduct(container);
                    break;

                case 5:
                    Cases.RemoveExistingProduct(container);
                    break;

                case 6:
                    Cases.PrintItemList(menu);
                    break;

                case 7:
                    Cases.AddMenuItem(menu, container);
                    break;

                case 8:
                    Cases.UpdateMenuItem(menu, container);
                    break;

                case 9:
                    Cases.DeleteMenuItem(menu);
                    break;

                case 10:
                    Cases.NewOrder(menu, container, orderList);
                    break;

                case 11:
                    Cases.PrintOrders(orderList);
                    break;

                case 0:
                    Services.File.writeStocRecord(container.ProductList, "Stock.txt");
                    Services.File.writeMenuRecord(menu.menuItems, "Menu.txt");
                    Services.File.writeOrdersRecord(orderList.orderList, "Orders.txt");
                    return;

                default:
                    Console.WriteLine("Default case");
                    break;
                }
                Console.WriteLine();
            }
        }