// GET: Experience/Edit/{id} public ActionResult Edit(int experienceId) { var detail = _experienceService.GetExperienceDetailById(experienceId); var model = new ExperienceUpdateModel { ExperienceId = detail.ExperienceId, Name = detail.Name, ChallengeScoreIncrease = detail.ChallengeScoreIncrease, }; return(View(model)); }
public bool Edit(ExperienceUpdateModel model) { var entity = _ctx.Experiences.Single(e => e.ExperienceId == model.ExperienceId); if (entity != null) { entity.Name = model.Name; entity.ChallengeScoreIncrease = model.ChallengeScoreIncrease; entity.RoadMaps = model.RoadMaps; entity.Comments = model.Comment; } return(_ctx.SaveChanges() == 1); }
public ActionResult Edit(ExperienceUpdateModel model, int experienceId) { if (model.ExperienceId != experienceId) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } if (_experienceService.Edit(model)) { TempData["SaveResult"] = "Experience edited"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Unable to edit experience"); return(View(model)); }