/// <summary>
        /// UI to add a product
        /// </summary>
        private void AddAProduct()
        {
            Console.WriteLine("\nEnter the details of the product you want to add");
            string itemName    = _validate.ValidateString("Enter the product name: ");
            double price       = _validate.ValidatePrice("Enter the price of the product: ");
            string description = _validate.ValidateString("Enter a description for the product: ");

            Log.Information("Product information input");
            try {
                // New product model created and sent to Business Logic
                Product newProduct = new Product(itemName, price, description);
                Log.Information("UI sent new product to BL");
                Product         createdProduct  = _productBL.AddProduct(newProduct);
                List <int>      productQuantity = new List <int>();
                List <Location> locations       = _locationBL.GetAllLocations();
                List <Product>  products        = _productBL.GetAllProducts();
                // Ensure quantity is set to 0 for all locations so customer may not purchase before stocked
                foreach (Product item in products)
                {
                    productQuantity.Add(0);
                }
                foreach (Location location in locations)
                {
                    Log.Information("UI sent updated inventory to BL");
                    _inventoryBL.ReplenishInventory(location.StoreName, productQuantity);
                }
                Console.WriteLine("New Product Created\n");
                Console.WriteLine(createdProduct.ToString());
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
        public void ViewAllLocations()
        {
            List <Location> locations = _locationBL.GetAllLocations();
            Action <Object> print     = o => Console.WriteLine(o.ToString());

            if (locations.Count == 0)
            {
                Console.WriteLine("No location :< You should add some");
            }
            else
            {
                locations.ForEach(print);
            }
        }
Exemple #3
0
        private void DisplayBranchLocations()
        {
            List <Location> locations = _locationBL.GetAllLocations();
            var             table     = new ConsoleTable("Branch Id", "Branch Location Name", "Address");

            var currentColor = Console.ForegroundColor;

            foreach (Location l in locations)
            {
                table.AddRow(l.Id, l.Name, l.Address);
                Console.ForegroundColor = ConsoleColor.Green;
            }
            table.Write();
            Console.ForegroundColor = currentColor;
        }
        public string LocationFind()
        {
            bool iterate = true;

            do
            {
                Console.WriteLine("Which store do you wish to purchase it from?");
                List <Location> locations = _locationBL.GetAllLocations();
                foreach (Location location in locations)
                {
                    Console.WriteLine(location.ToString());
                }
                ;
                int code = _verify.VerifyInt("Please select a number (0 is PA, 1 is TX, 2 is CA)");
                switch (code)
                {
                case 0:
                    return("PA");

                    break;

                case 1:
                    return("TX");

                    break;

                case 2:
                    return("CA");

                    break;

                default:
                    Console.WriteLine("Please enter a valid number");
                    break;
                }
            } while (iterate);
            return("random");
        }