private Dictionary <Shop, List <Product> > FindAllShopsWithProduct(List <AProduct> products)
        {
            ShopEqualityComparer comparer            = new ShopEqualityComparer();
            Dictionary <Shop, List <Product> > shops = new Dictionary <Shop, List <Product> >(comparer);

            for (int i = 0; i < products.Count; i++)
            {
                AProduct prod      = products[i];
                var      pair_list = dao.GetProduct(prod.Type, prod.Name);
                foreach (Pair <Shop, Product> pair in pair_list)
                {
                    Shop    shop    = pair.First;
                    Product product = pair.Second;

                    if (!shops.ContainsKey(shop))
                    {
                        shops.Add(shop, new List <Product>());
                    }

                    shops.TryGetValue(shop, out List <Product> list);
                    list.Add(product);
                }
            }

            return(shops);
        }
        private Dictionary <Shop, double> FindAppropriateShops(Dictionary <Shop, List <Product> > shops,
                                                               List <AProduct> products, List <int> amounts)
        {
            ShopEqualityComparer      comparer = new ShopEqualityComparer();
            Dictionary <Shop, double> result   = new Dictionary <Shop, double>(comparer);

            foreach (KeyValuePair <Shop, List <Product> > pair in shops)
            {
                List <Product> list = pair.Value;
                if (list.Count != products.Count)
                {
                    continue;
                }

                bool   fine = true;
                double cost = 0;
                for (int i = 0; i < products.Count; i++)
                {
                    if (list[i].Amount < amounts[i])
                    {
                        fine = false;
                        break;
                    }

                    cost += amounts[i] * list[i].Price;
                }

                if (!fine)
                {
                    continue;
                }

                result.Add(pair.Key, cost);
            }

            return(result);
        }