public ActionResult Edit(int id) { GameModel gamemodel = db.GameModels.Find(id); GameModificationViewModel viewModel = new GameModificationViewModel() { Name = gamemodel.Name, GameId = gamemodel.GameId, }; return View(viewModel); }
public ActionResult Edit(GameModificationViewModel gamemodel) { using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew)) { try { var editGame = new EditGame(gamemodel, db); editGame.DoTransaction(); transactionScope.Complete(); } catch (Exception e) { ModelState.AddModelError("", "Change set is corrupted or someone modified model in same time"); return View(gamemodel); } } return RedirectToAction("Index"); }
public EditGame(GameModificationViewModel gameModel, GameContext db) { this.gameModel = gameModel; this.db = db; }