public IActionResult Update(string id) { var travelPackage = _travelPackageDataService.GetSingle(tp => tp.TravelPackageId == id); var updateViewModel = new TravelPackageUpdateViewModel { Activated = travelPackage.Activated, Description = travelPackage.Description, Location = travelPackage.Location, Name = travelPackage.Name, Price = travelPackage.Price, TravelPackageId = travelPackage.TravelPackageId }; return(View(updateViewModel)); }
public IActionResult Update(TravelPackageUpdateViewModel vm) { if (ModelState.IsValid) { var travelPackage = _travelPackageDataService .GetSingle(tp => tp.TravelPackageId == vm.TravelPackageId); if (travelPackage != null) { travelPackage.Activated = vm.Activated; travelPackage.Description = vm.Description; travelPackage.Location = vm.Location; travelPackage.Name = vm.Name; travelPackage.Price = vm.Price; _travelPackageDataService.Update(travelPackage); } return(RedirectToAction("All", "TravelPackage")); } return(View(vm)); }