public ActionResult AddCar(Car car) { CarsWithCheckboxDb db = new CarsWithCheckboxDb(_connectionString); db.AddCar(car); return(Redirect("/")); }
public IActionResult Index(string sort) { CarsWithCheckboxDb db = new CarsWithCheckboxDb(_connectionString); IEnumerable <Car> cars = db.GetCars(); if (sort == "asc") { cars = cars.OrderBy(c => c.Year); } else if (sort == "desc") { cars = cars.OrderByDescending(c => c.Year); } HomePageViewModel vm = new HomePageViewModel(); vm.Cars = cars; vm.SortAsc = sort == "asc"; return(View(vm)); }