public static void AddGame(string name, string uploader, string game) { Games addThis = new Games(); using (var dbCtx = new GrafilogikaDBEntities()) { try { addThis.Name = name; addThis.Uploader = uploader; addThis.Wins = 0; addThis.Rating = 0; addThis.Mistakes = 0; addThis.Game = game; dbCtx.Games.Add(addThis); dbCtx.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.StackTrace); } } }
public static void UpdateGameWins(Games game) { using (var dbCtx = new GrafilogikaDBEntities()) { try { if (game.Wins == null) { game.Wins = 0; } game.Wins++; dbCtx.Entry(game).State = EntityState.Modified; dbCtx.SaveChanges(); } catch (Exception) { throw; } } }
public static void UpdateGameRating(Games game, int rating) { using (var dbCtx = new GrafilogikaDBEntities()) { try { if (game.Rating == null || game.Rating == 0) { game.Rating = rating; } else { game.Rating += rating; } dbCtx.Entry(game).State = EntityState.Modified; dbCtx.SaveChanges(); } catch (Exception) { throw; } } }
public ActionResult DeleteGame(Games selectedGame) { DBManager.DeleteGameByName(selectedGame.Name); return RedirectToAction("MyProfile", "Home"); }
public ActionResult LoadGame(Games selectedGame) { //Games selectedGame = DBManager.GetGameByName(name); return RedirectToAction("Game", "Game", new { gameName = selectedGame.Name}); }