Exemple #1
0
        static void ShowProductAmountRange()
        {
            Console.WriteLine("~~~~~~~~~~ Qiymət araliğinda Mehsullar ~~~~~~~~~~ ");
            Console.WriteLine("");
            #region Start Amount
            Console.WriteLine("Başlanğic qiyməti daxil edin:");
            string startAmountInput = Console.ReadLine();
            double startAmount;

            while (!double.TryParse(startAmountInput, out startAmount))
            {
                Console.WriteLine("Rəqəm daxil edin");
                startAmountInput = Console.ReadLine();
            }
            #endregion

            #region End Amount

            Console.WriteLine("Son qiyməti daxil edin");
            string endAmountInput = Console.ReadLine();
            double endAmount;

            while (!double.TryParse(endAmountInput, out endAmount))
            {
                Console.WriteLine("Rəqem daxil edin");
                endAmountInput = Console.ReadLine();
            }
            #endregion

            List <Product> products = _marketableService.GetProductByAmountRange(startAmount, endAmount);
            if (startAmount > endAmount)
            {
                Console.WriteLine("");
                Console.WriteLine("____Başlanğic qiymət, son qiymətdən kiçik  olmalidir___");
                Console.WriteLine("");
            }
            else
            {
                if (products.Count == 0)
                {
                    Console.WriteLine("məhsul yoxdur");
                }
                else
                {
                    var table = new ConsoleTable("No", "Kategoriya", "Məhsul", "Sayı", "Qiyməti", "Məhsul kodu");
                    int i     = 1;
                    foreach (var item in products)
                    {
                        table.AddRow(i, item.Category, item.ProductName, item.ProductQuantity, item.ProductPrice, item.ProductCode);
                        i++;
                    }
                    table.Write();
                }
            }
        }
        static void GetProductByAmountRange()
        {
            Console.WriteLine("Min mebleq daxil edin");
            string Amount = Console.ReadLine();
            double minAmount;

            while (!double.TryParse(Amount, out minAmount))
            {
                Console.WriteLine("Duzgun mebleg daxil edin");
                Amount = Console.ReadLine();
            }
            Console.WriteLine("Max mebleq daxil edin");
            string Amount2 = Console.ReadLine();
            double maxAmount;

            while (!double.TryParse(Amount2, out maxAmount))
            {
                Console.WriteLine("Duzgun mebleg daxil edin");
                Amount2 = Console.ReadLine();
            }
            if (maxAmount < minAmount)
            {
                Console.WriteLine("Max mebleg Min mebleqden boyuk olmalidir");
            }
            else
            {
                var list = marketableService.GetProductByAmountRange(minAmount, maxAmount);
                if (list.Count == 0)
                {
                    Console.WriteLine("Mehsul yoxdur");
                }
                else
                {
                    var table = new ConsoleTable("Mehsul", "Mehsulun adi", "Mehsulun Kodu", "Mehsulun sayi", "Mehsulun qiymeti", "Mehsulun Kateqoriyasi");
                    int i     = 1;
                    foreach (var item in list)
                    {
                        _ = table.AddRow(i, item.ProductName, item.ProductCode, item.ProductCount, item.ProductPrice, item.Category);
                        i++;
                    }

                    table.Write();
                }
            }
        }