public ActionResult Create(GameVersion version) { if (ModelState.IsValid) { db.Versions.Add(version); db.SaveChanges(); return RedirectToAction("Edit", "GameVersion", new { id = version.GameVersionID }); } return View(version); }
public ActionResult Edit(GameVersion version) { if (ModelState.IsValid) { db.Entry(version).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Edit", new { id=version.GameVersionID }); } return View(version); }
public ActionResult Release(int id) { GameVersion version = db.Versions.Find(id); Game game = version.ParentGame; int parentId = game.GameID; PlayerIdentity playerIdentity = (PlayerIdentity)User.Identity; Player player = db.Players.Where(p => p.Name == playerIdentity.Name).Single(); if (player.PlayerID != game.CreatorId) RedirectToAction("DeveloperProfile", "Home"); GameVersion newVersion = new GameVersion { ModuleName = version.ModuleName, VersionString = version.VersionString, PythonScript = version.PythonScript, MaxPlayers = version.MaxPlayers, ParentGame = version.ParentGame, CreationDate = DateTime.Now, StatLog = "[]", DevStage = "Alpha" }; game.Versions.Add(newVersion); version.DevStage = "Release"; version.CreationDate = DateTime.Now; version.VersionString = "X"; db.SaveChanges(); return RedirectToAction("Edit", "Game", new { id = parentId }); }