[Route("cars/list/{orderby?}")] // URL: https://localhost:5001/cars/list/color public IActionResult List(string orderby) { // Andy: Check for null if (orderby == null) { orderby = ""; } //MakeModel, Year, Price, Milage, Color CarContext.SortOrder sortOrder; sortOrder = CarContext.SortOrder.Year; orderby = orderby.ToLower(); switch (orderby) { case "id": sortOrder = CarContext.SortOrder.ID; break; case "make": sortOrder = CarContext.SortOrder.MakeModel; break; case "mileage": sortOrder = CarContext.SortOrder.Mileage; break; case "price": sortOrder = CarContext.SortOrder.Price; break; case "color": sortOrder = CarContext.SortOrder.Color; break; case "year": sortOrder = CarContext.SortOrder.Year; break; } List <Car> sortedCars = CarContext.sortBy(sortOrder, true); return(View(sortedCars)); }