public bool ShowProductsByConfigurations(List <Configuration> configurations, List <Part> cartP, List <Module> cartM, List <Configuration> cartC) { while (true) { int counter = 1; Console.Clear(); foreach (var configuration in configurations) { Console.WriteLine($"{counter}. Configuration Name: {configuration.Title}"); counter++; Console.WriteLine(); foreach (var module in configuration.Modules) { Console.WriteLine($"Module Name: {module.Type}"); foreach (var part in module.Parts) { Console.WriteLine($"Part: {part.Name}"); } Console.WriteLine(); } Console.WriteLine("--------------------------------"); } Console.WriteLine("Choose product to buy:"); int input = int.Parse(Console.ReadLine()); if (input < 1 || input > counter) { Console.WriteLine("Enter valid number. Press any key and try again!"); Console.ReadLine(); continue; } else { int brojce = UiService.HowMany(); for (int i = 0; i < brojce; i++) { cartC.Add(configurations[input - 1]); } var boughtPart = configurations[input - 1]; Console.WriteLine($"Product of type: {boughtPart.Type} {boughtPart.Title} is added to your cart! Quantity: {brojce}"); var nesto = UiService.NextAction(ShowProductsByConfigurations, configurations, cartP, cartM, cartC); return(nesto); } } }
public bool ShowByPriceOfModules(List <Module> modules, List <Part> cartP, List <Module> cartM, List <Configuration> cartC) { while (true) { int min = 0; int max = 0; while (true) { Console.Clear(); Console.WriteLine("Lowest is 100 dollars, Highest is 840. Enter between these numbers:"); Console.WriteLine("Enter minimum price of Module:"); min = int.Parse(Console.ReadLine()); if (min < 100 || min > 840) { Console.WriteLine("Enter valid number.Press any key."); Console.ReadLine(); continue; } else { break; } } while (true) { Console.Clear(); Console.WriteLine("Enter maximum price of Part:"); max = int.Parse(Console.ReadLine()); if (max < min || max > 840) { Console.WriteLine("Enter valid number.Press any key."); Console.ReadLine(); continue; } else { break; } } var itemList = modules.Where(x => x.Price > min && x.Price < max).ToList(); if (itemList.Count == 0) { Console.WriteLine("There are no parts in that range! Please try again.Press any key."); Console.ReadLine(); continue; } Console.Clear(); int counter = 1; foreach (var item in itemList) { Console.WriteLine($"{counter}. Name: {item.Type}, Price: {item.Price}"); counter++; } Console.WriteLine("Choose Product to buy:"); int input = int.Parse(Console.ReadLine()); if (input < 1 || input > counter) { Console.WriteLine("Enter valid number. Press any key and try again!"); Console.ReadLine(); continue; } else { var brojce = UiService.HowMany(); for (int i = 0; i < brojce; i++) { cartM.Add(itemList[input - 1]); } Module boughtPart = itemList[input - 1]; Console.WriteLine($"Product of type: {boughtPart.Type} is added to your cart! Quantity: {brojce}"); var nesto = UiService.NextAction(ShowByPriceOfModules, modules, cartP, cartM, cartC); return(nesto); } } }