public IActionResult UpdatePackages(int id, UpdatePackageDetailsViewModel vm) { Package pac = _repoPackage.GetSingle(p => p.PackageId == id); if (pac != null && ModelState.IsValid) { pac.Details = vm.Details; pac.Location = vm.Location; pac.Price = vm.Price; pac.Availability = vm.Availability; //Save the updated Package to DB _repoPackage.Update(pac); //Redirect to Packages return(RedirectToAction("Packages")); } return(View(vm)); }
public IActionResult UpdatePackages(int id) { //Get the Package from the DB Package pac = _repoPackage.GetSingle(p => p.PackageId == id); if (pac == null) { return(RedirectToAction("Index")); } //Create the vm UpdatePackageDetailsViewModel vm = new UpdatePackageDetailsViewModel { Details = pac.Details, Location = pac.Location, Price = pac.Price, Availability = pac.Availability }; return(View(vm)); }