public static RefinementGroup ConvertToRefinementGroup(this IEnumerable<IProductAttribute> productAttributes, RefinementGroupings refinementGroupType)
        {
            RefinementGroup refinementGroup = new RefinementGroup() { Name = refinementGroupType.ToString(), GroupId = (int)refinementGroupType };

            refinementGroup.Refinements = Mapper.Map<IEnumerable<IProductAttribute>, IEnumerable<Refinement>>(productAttributes);

            return refinementGroup;
        }
        private static IList<RefinementGroup> GenerateAvailableProductRefinementsFrom(IEnumerable<ProductDto> productsFound)
        {
            var brandsMatching =
                new RefinementGroup()
                    {
                        Refinements = productsFound.Select(p => new Refinement() {Id = p.BrandId, Name = p.BrandName}).Distinct(r => r.Id),
                        GroupId = (int)RefinementGroupings.brand,
                        Name = RefinementGroupings.brand.ToString()
                    };

            var coloursMatching =
                new RefinementGroup()
                {
                    Refinements = productsFound.Select(p => new Refinement() { Id = p.ColourId, Name = p.ColourName }).Distinct(r => r.Id),
                    GroupId = (int)RefinementGroupings.colour,
                    Name = RefinementGroupings.colour.ToString()
                };

            var sizesMatching =
                new RefinementGroup()
                {
                    Refinements = productsFound.Select(p => new Refinement() { Id = p.SizeId, Name = p.SizeName }).Distinct(r => r.Id),
                    GroupId = (int)RefinementGroupings.size,
                    Name = RefinementGroupings.size.ToString()
                };

            //var brandsRefinementGroup = productsFound.Select(p => p.Brand).Distinct().ToList()
            //                           .ConvertAll<IProductAttribute>(b => (IProductAttribute)b).ConvertToRefinementGroup(RefinementGroupings.brand);
            //var coloursRefinementGroup = productsFound.Select(p => p.Colour).Distinct().ToList()
            //                           .ConvertAll<IProductAttribute>(c => (IProductAttribute)c).ConvertToRefinementGroup(RefinementGroupings.colour);
            //var sizesRefinementGroup = (from p in productsFound
            //                            from si in p.Products
            //                            select si.Size).Distinct().ToList()
            //                           .ConvertAll<IProductAttribute>(s => (IProductAttribute)s).ConvertToRefinementGroup(RefinementGroupings.size);

            IList<RefinementGroup> refinementGroups = new List<RefinementGroup>();

            refinementGroups.Add(brandsMatching);
            refinementGroups.Add(coloursMatching);
            refinementGroups.Add(sizesMatching);
            return refinementGroups;
        }