public static IQueryable <Post> FilterBy(this IQueryable <Post> source, bool byAccomodation = false,
                                                 AccomodationOptions accomodationOptions            = AccomodationOptions.Without,
                                                 bool byPrice = false, decimal minPrice = 0, decimal maxPrice = decimal.MaxValue, bool byCity = false,
                                                 IEnumerable <City> cities = null)
        {
            if (byAccomodation)
            {
                source = source.Where(post => post.AccomodationOption == accomodationOptions);
            }
            if (byPrice)
            {
                source = source.Where(post => post.Price > minPrice && post.Price < maxPrice);
            }
            if (!byCity)
            {
                return(source);
            }
            {
                if (cities == null)
                {
                    return(source);
                }
                var list = cities.Select(c => c.Id);
                source = source.Where(post => post.Neighborhoods.Any(neigh => list.Contains(neigh.City.Id)));
            }

            return(source);
        }
 public FilterManager(bool byAccomodation = false,
                      AccomodationOptions accomodationOptions = AccomodationOptions.Without,
                      bool byPrice  = false, decimal minPrice = 0, decimal maxPrice = decimal.MaxValue, bool byCity = false,
                      string cities = null)
 {
     ByAccomodation      = byAccomodation;
     AccomodationOptions = accomodationOptions;
     ByPrice             = byPrice;
     MinPrice            = minPrice;
     MaxPrice            = maxPrice;
     ByCity = byCity;
     City   = cities;
 }