public ActionResult Edit([Bind(Include = "PlayerID,AchievementName,Number")] PlayerAchievement playerAchievement) { if (ModelState.IsValid) { _repository.EditPlayerAchievement(playerAchievement); return(RedirectToAction("Index", "PlayerAchievements", new { id = playerAchievement.PlayerID })); } ViewBag.AchievementName = new SelectList(_achievementRepository.GetAchievements(), "Name", "ImageLink", playerAchievement.AchievementName); return(View(playerAchievement)); }
public ActionResult Edit(PlayerAchievement playerAchievement) { if (ModelState.IsValid) { try { _repository.EditPlayerAchievement(playerAchievement); return(RedirectToAction("Index")); } catch (Exception ex) { //error msg for failed edit in XML file ModelState.AddModelError("", "Error editing record. " + ex.Message); } } return(View(playerAchievement)); }