/// <summary> /// Requests all products available in the office and prints them. /// </summary> private void ViewAllProducts() { Console.Clear(); Console.WriteLine(new string('-', 40)); Console.WriteLine(new string(' ', 14) + "ALL PRODUCTS"); Console.WriteLine(new string('-', 40) + '\n'); string name; while (true) { Console.Write("Office name: "); name = Console.ReadLine(); Console.WriteLine(); if (OfficeBusiness.OfficeExists(name)) { break; } Console.WriteLine(new string('-', 26)); Console.WriteLine("Please enter a valid office name!"); Console.WriteLine(new string('-', 26) + '\n'); } Console.WriteLine(OfficeBusiness.AllProductsAvailableInOffice(OfficeBusiness.GetID(name))); Console.ReadKey(); }
/// <summary> /// Requests a new office to be created. /// </summary> private void CreateOffice() { string name, city, address, phone; Console.Clear(); Console.WriteLine(new string('-', 40)); Console.WriteLine(new string(' ', 14) + "Create Office"); Console.WriteLine(new string('-', 40) + '\n'); while (true) { Console.Write("Office name: "); name = Console.ReadLine(); Console.WriteLine(); if (!OfficeBusiness.OfficeExists(name)) { break; } Console.WriteLine(new string('-', 26)); Console.WriteLine("Please enter a valid office name!"); Console.WriteLine(new string('-', 26) + '\n'); } while (true) { Console.Write("City: "); city = Console.ReadLine(); Console.WriteLine(); if (city.Length > 2) { break; } Console.WriteLine(new string('-', 26)); Console.WriteLine("Please enter a valid city name!"); Console.WriteLine(new string('-', 26) + '\n'); } while (true) { Console.Write("Address: "); address = Console.ReadLine(); Console.WriteLine(); if (address.Length > 6) { break; } Console.WriteLine(new string('-', 26)); Console.WriteLine("Please enter a valid address!"); Console.WriteLine(new string('-', 26) + '\n'); } while (true) { Console.Write("Phone: "); phone = Console.ReadLine(); Console.WriteLine(); if (phone.Length > 9) { break; } Console.WriteLine(new string('-', 26)); Console.WriteLine("Please enter a valid phone number!"); Console.WriteLine(new string('-', 26) + '\n'); } OfficeBusiness.CreateOffice(name, city, address, phone); }
/// <summary> /// Request a shipping from one office to another. /// </summary> private void ShipProduct() { string officeNameFrom, officeNameTo, productName; Console.Clear(); Console.WriteLine(new string('-', 40)); Console.WriteLine(new string(' ', 14) + "SHIP PRODUCT"); Console.WriteLine(new string('-', 40)); Console.WriteLine(); while (true) { Console.Write("Office name(from): "); officeNameFrom = Console.ReadLine(); Console.WriteLine(); if (OfficeBusiness.OfficeExists(officeNameFrom)) { break; } Console.WriteLine(new string('-', 26)); Console.WriteLine("Please enter a valid office name!"); Console.WriteLine(new string('-', 26) + '\n'); } while (true) { Console.Write("Office name(to): "); officeNameTo = Console.ReadLine(); Console.WriteLine(); if (OfficeBusiness.OfficeExists(officeNameTo)) { break; } Console.WriteLine(new string('-', 26)); Console.WriteLine("Please enter a valid office name!"); Console.WriteLine(new string('-', 26) + '\n'); } while (true) { Console.Write("Product name: "); productName = Console.ReadLine(); Console.WriteLine(); if (OfficeBusiness.ProductAvailable(OfficeBusiness.GetID(officeNameFrom), ProductBusiness.GetID(productName))) { break; } Console.WriteLine(new string('-', 27)); Console.WriteLine("Please enter a valid price!"); Console.WriteLine(new string('-', 27) + '\n'); } OfficeBusiness.TransferProduct(OfficeBusiness.GetID(officeNameFrom), OfficeBusiness.GetID(officeNameTo), ProductBusiness.GetID(productName)); }
/// <summary> /// Request a product to be loaded to an office. /// </summary> private void LoadProduct() { string officeName, distributorName, productName; int stock; Console.Clear(); Console.WriteLine(new string('-', 40)); Console.WriteLine(new string(' ', 14) + "LOAD PRODUCT"); Console.WriteLine(new string('-', 40) + '\n'); while (true) { Console.Write("Office name: "); officeName = Console.ReadLine(); Console.WriteLine(); if (OfficeBusiness.OfficeExists(officeName)) { break; } Console.WriteLine(new string('-', 26)); Console.WriteLine("Please enter a valid office name!"); Console.WriteLine(new string('-', 26) + '\n'); } while (true) { Console.Write("Distributor name: "); distributorName = Console.ReadLine(); Console.WriteLine(); if (!(distributorName.Length < 1) && DistributorBusiness.DistributorExists(DistributorBusiness.GetID(distributorName))) { break; } Console.WriteLine(new string('-', 26)); Console.WriteLine("Please enter a valid name!"); Console.WriteLine(new string('-', 26) + '\n'); } while (true) { Console.Write("Product name: "); productName = Console.ReadLine(); Console.WriteLine(); if (DistributorBusiness.CheckForProduct(DistributorBusiness.GetID(distributorName), ProductBusiness.GetID(productName))) { break; } Console.WriteLine(new string('-', 27)); Console.WriteLine("Please enter a valid price!"); Console.WriteLine(new string('-', 27) + '\n'); } while (true) { Console.Write("Stock: "); stock = int.Parse(Console.ReadLine()); Console.WriteLine(); if (!(stock < 0)) { break; } Console.WriteLine(new string('-', 27)); Console.WriteLine("Please enter a valid stock!"); Console.WriteLine(new string('-', 27) + '\n'); } OfficeBusiness.LoadProduct(OfficeBusiness.GetID(officeName), DistributorBusiness.GetProduct(DistributorBusiness.GetID(distributorName), ProductBusiness.GetID(productName)), stock); }