//GET: Combat/Edit/{id} public ActionResult Edit(int id) { var svc = CreateCombatService(); var detail = svc.GetCombatByID(id); var model = new CombatEdit() { CombatID = detail.CombatID, Name = detail.Name }; return(View(model)); }
public bool UpdateCombat(CombatEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Combats .Single(e => e.CombatID == model.CombatID && e.OwnerID == _userID); entity.Name = model.Name; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, CombatEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.CombatID != id) { ModelState.AddModelError("", "ID does not match"); return(View(model)); } var svc = CreateCombatService(); if (svc.UpdateCombat(model)) { TempData["SaveResult"] = "Combat Updated"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Combat could not be updated"); return(View(model)); }