Ejemplo n.º 1
0
        // GET: Car
        public async Task <ActionResult> Index(int?carID, string sortOrder)
        {
            var car = from s in db.Car
                      select s;

            if (carID != null && carID > 0)
            {
                car = car.Where(d => d.ID == carID);
            }

            var sortDirection = ControllerHelper.GetSortOrder(sortOrder);

            UpdateSortDirection(sortDirection);
            car = CarManager.AddSortToQuery(car, sortOrder);

            List <Car> carListItems = car.ToList <Car>();

            ViewBag.CarList = carListItems;

            return(View(await car.ToListAsync()));
        }