Пример #1
0
    private static void FindByPriceRangeMethod(string input, ProductCollection colection)
    {
        int    index;
        string input2;

        string[] separatedByComma;
        index            = input.IndexOf(' ');
        input2           = input.Substring(index + 1);
        separatedByComma = input2.Split(';');
        decimal startPrice = decimal.Parse(separatedByComma[0]);
        decimal endPrice   = decimal.Parse(separatedByComma[1]);

        var list = colection.FindProductsByPriceRange(startPrice, endPrice);

        if (!list.Any())
        {
            Console.WriteLine("No products found");
        }
        else
        {
            foreach (var item in list)
            {
                Console.Write("{");
                Console.Write("{0};{1};{2:f2}", item.Name, item.Producer, item.Price);
                Console.WriteLine("}");
            }
        }
    }