Exemplo n.º 1
0
        public void PrintInventory(int storeID, Dictionary <Product, int> cart)
        {
            Store store = StoreRepo.GetStoreByID(storeID);

            if (store.Inventory.Count == 0)
            {
                Outputter.WriteLine("Inventory is empty.");
            }
            else
            {
                Outputter.WriteLine("ID\t\tName\t\tPrice\t\tQuantity");
                foreach (var item in store.Inventory)
                {
                    int inOrder = 0;
                    foreach (var cartItem in cart)
                    {
                        if (cartItem.Key.ID == item.Key.ID)
                        {
                            inOrder = cartItem.Value;
                        }
                    }
                    Outputter.WriteLine($"{item.Key.ID}\t\t{item.Key.Name}\t\t${item.Key.Price}\t\t{item.Value-inOrder} Available");
                }
            }
        }
Exemplo n.º 2
0
        public void PrintInventory(int storeID)
        {
            Store store = StoreRepo.GetStoreByID(storeID);

            if (store.Inventory.Count == 0)
            {
                Outputter.WriteLine("Inventory is empty.");
            }
            else
            {
                Outputter.WriteLine("ID\t\tName\t\tPrice\t\tQuantity");
                foreach (var item in store.Inventory)
                {
                    Outputter.WriteLine($"{item.Key.ID}\t\t{item.Key.Name}\t\t${item.Key.Price}\t\t{item.Value} Available");
                }
            }
        }
Exemplo n.º 3
0
        public void Run()
        {
            bool  running      = true;
            Store currentStore = null;

            while (running)
            {
                while (currentStore == null)
                {
                    PrintStoreLocations();
                    Outputter.Write("Enter a store ID to shop from or type '0' to add a new location: ");
                    int location = Inputter.GetIntegerInput();
                    if (location != 0)
                    {
                        try
                        {
                            currentStore = StoreRepo.GetStoreByID(location);
                        }
                        catch (Exception)
                        {
                            Outputter.WriteLine("Store location does not exist!");
                        }
                    }
                    else
                    {
                        Outputter.Write("Enter a name for the store: ");
                        string storeName = Inputter.GetAnyInput();
                        Outputter.Write("Enter the stores city: ");
                        string storeCity = Inputter.GetStringInput();
                        Outputter.Write("Enter the stores state: ");
                        string storeState = Inputter.GetStringInput();
                        StoreRepo.AddStore(new Store(storeName, storeCity, storeState));
                    }
                }
                int option = 0;
                while (!(option > 0 && option < 10))
                {
                    Outputter.WriteLine("Choose an option:\n[1] Add Customer\n[2] Search Customers\n[3] Place order for customer\n[4] Display order details\n[5] Display customer order history\n[6] Display store order history\n[7] Edit inventory\n[8] Change store locations\n[9] Quit");
                    option = Inputter.GetIntegerInput();
                }
                switch (option)
                {
                case 1:
                    AddNewCustomer();
                    break;

                case 2:
                    SearchCustomerByID();
                    break;

                case 3:
                    PrintCustomerList();
                    PlaceNewOrder(currentStore);
                    break;

                case 4:
                    DisplayOrderDetails();
                    break;

                case 5:
                    DisplayCustomerOrders();
                    break;

                case 6:
                    PrintStoreOrderHistory(currentStore);
                    break;

                case 7:
                    EditInventory(currentStore);
                    break;

                case 8:
                    currentStore = null;
                    break;

                case 9:
                    running = false;
                    break;
                }
            }
        }