Exemple #1
0
        //public readonly MongoCmsContext Context = new MongoCmsContext();

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

            return(View(model));
        }
        public async Task <ActionResult> Index(RentalsFilter filters)
        {
            var filterDefinition = filters.ToFilterDefinition();

            //Find way
            //var rentals = await Context.Rentals
            //    .Find(filterDefinition)
            //    .SortBy(r => r.Price)
            //    .ThenByDescending(r => r.NumberOfRooms)
            //    .ToListAsync();
            //Linq

            var rentals = await FilterRentals(filters)
                          .OrderBy(r => r.Price)
                          .ThenByDescending(r => r.NumberOfRooms)
                          .ToListAsync();

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

            return(View(model));
        }
        public ActionResult Index(RentalsFilter filters)
        {
            var rentals = FilterRentals(filters);

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

            return View(model);
        }
Exemple #4
0
        public async Task <ActionResult> Index(RentalsFilter filters)
        {
            //var rentals = FilterRentals(filters);

            //var rentals = await ContextNew.Rentals
            //    .Find(new BsonDocument())
            //    .ToListAsync();

            //var filterDefinition = Builders<Rental>.Filter.Where(r => r.NumberOfRooms >= filters.MinimumRooms);
            //var rentals = await ContextNew.Rentals
            //    .Find(filterDefinition)
            //    .ToListAsync();

            //var rentals = await ContextNew.Rentals
            //    .Find(filters.ToFilterDefinition())
            //    .Project(r => new RentalViewModel
            //    {
            //        Id = r.Id,
            //        Description = r.Description,
            //        NumberOfRooms = r.NumberOfRooms,
            //        Price = r.Price,
            //        Address = r.Address
            //    })
            //    //.Sort(Builders<Rental>.Sort.Ascending(r => r.Price))
            //    .SortBy(r => r.Price)
            //    .ThenByDescending(r => r.NumberOfRooms)
            //    .ToListAsync();

            var rentals = await FilterRentals(filters)
                          .Select(r => new RentalViewModel
            {
                Id            = r.Id,
                Description   = r.Description,
                NumberOfRooms = r.NumberOfRooms,
                Price         = r.Price,
                Address       = r.Address
            })
                          .OrderBy(r => r.Price)
                          .ThenByDescending(r => r.NumberOfRooms)
                          .ToListAsync();

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

            return(View(model));
        }
        // GET: Rentals
        public ActionResult Index(RentalsFilter filters)
        {
            if (filters.MinimumRooms == null)
            {
                filters.MinimumRooms = 0;
                filters.PriceLimit   = 1000000;
            }
            var rentals = FilterRentals(filters);
            var model   = new RentalsList
            {
                Rentals = rentals,
                Filters = filters
            };

            return(View(model));
        }
Exemple #6
0
        // GET: Rentals
        public async Task<ActionResult> Index(RentalFilter filter)
        {
            IEnumerable<Rental> rentals = null;
            if (filter == null)
            {
                var bsonFilter = new BsonDocument();
                //Simple test for CoreControl
                //var generic = await Context.GenericData_Alerts.FindAsync<Models.GenericData_Alerts>(filter).ToListAsync();
                rentals = await Context.Rentals.FindAsync<Rental>(bsonFilter).ToListAsync();
            }
            else
                rentals = await FilterRentals(filter);

            var model = new RentalsList
            {
                RentalFilter = filter,
                Rentals = rentals
            };
            return View(model);
        }