} //4 static void GetProductsByCategory() { Products prod = new Products(); Console.WriteLine("------ Categoriyasina gore mehsullari goster-----\n"); Array array = Enum.GetValues(typeof(Category)); foreach (var item in array) { Console.WriteLine(Array.IndexOf(array, item) + " - " + item); } //((Category)category Console.WriteLine("Categoriyani daxil edin:"); int categoryNumberInt; string categoryNumber = Console.ReadLine(); while (!int.TryParse(categoryNumber, out categoryNumberInt)) { Console.WriteLine("reqem daxil edin:"); categoryNumber = Console.ReadLine(); } switch (categoryNumberInt) { case 1: prod.category = Category.Un_Mehsullari; break; case 2: prod.category = Category.Terevez; break; case 3: prod.category = Category.Cherezler; break; case 4: prod.category = Category.Ichkiler; break; case 5: prod.category = Category.Et_mehsullari; break; case 6: prod.category = Category.Gigyeniya_mehsullari; break; default: Console.WriteLine("sehv daxil etmisiz.1-6 araliginda reqem daxil edin:"); break; } marketableService.GetProductsByCategory((Category)categoryNumberInt); } //5
static void ShowProductsByCategory() { Product product = new Product(); Console.WriteLine("======================================================="); Console.WriteLine("-------- Kateqoriyasına görə məhsulları göstər --------"); Console.WriteLine("======================================================="); int selectInt; Console.WriteLine("Məhsulun kateqoriyasını daxil edin: "); Console.WriteLine("0.Telephone"); Console.WriteLine("1.Noutbook"); Console.WriteLine("2.Printer"); Console.WriteLine(""); Console.WriteLine("Seçiminizi daxil edin: "); string select = Console.ReadLine(); Console.WriteLine(""); while (!int.TryParse(select, out selectInt)) { Console.WriteLine("Rəqəm daxil etməlisiniz"); select = Console.ReadLine(); } switch (selectInt) { case 0: product.Category = Category.Telephone; break; case 1: product.Category = Category.Noutbook; break; case 2: product.Category = Category.Printer; break; default: Console.WriteLine(""); Console.WriteLine("Siz yanlış seçim etmisiniz,0-2 aralığında seçim etməlisiniz"); Console.WriteLine(""); ShowProductsByCategory(); break; } _marketableService.GetProductsByCategory((Category)selectInt); Console.WriteLine(""); Console.WriteLine("-------- Kateqoriyasına görə məhsullar göstərildi --------"); }
static void ShowProductsByCategory() { Category productCategory = SelectCategory(); Console.WriteLine("\nDaxil etdiyiniz kategoriyada ashagidaki mehsullar movcuddur"); var table = new ConsoleTable("No", "Adi", "Qiymeti", "Kategoriyasi", "Sayi", "Kodu"); int i = 1; foreach (var item in _marketableService.GetProductsByCategory(productCategory)) { table.AddRow(i, item.Name, item.Price.ToString("#.##"), item.ProductCategory, item.Quantity, item.Code); i++; } table.Write(); }