public ActionResult Index(RentalsFilter filters)
        {
            var rentals = FilterRentals(filters);

            //var rentals = FilterRentals(filters)
            //    .SetSortOrder(SortBy<Rental>.Ascending(r => r.Price)); //for MongoCursor<Rental>

            var model = new RentalsList()
            {
                Rentals = rentals,
                Filters = filters
            };

            return(View(model));
        }
        private IEnumerable <Rental> FilterRentals(RentalsFilter filters)
        {
            IQueryable <Rental> rentals = Context.Rentals.AsQueryable()
                                          .OrderBy(r => r.Price);

            if (filters.MinimumRooms.HasValue)
            {
                rentals = rentals
                          .Where(r => r.NumberOfRooms >= filters.MinimumRooms.Value);
                //var minRoom = Query<Rental>.LTE(r=>r.NumberOfRooms,filters.MinimumRooms);
                //rentals = rentals
                //    .Where(r => minRoom.Inject());
            }

            if (filters.PriceLimit.HasValue)
            {
                var query = Query <Rental> .LTE(r => r.Price, filters.PriceLimit);

                rentals = rentals
                          .Where(r => query.Inject());
            }

            return(rentals);
        }