public ActionResult Edit(Profile profile) { if (String.IsNullOrWhiteSpace(profile.Img)) { profile.Img = "/img/rubber-ducky.png"; } _db.Entry(profile).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details")); }
public ActionResult Play(int playerId, int gameId, int x, int y) { Game currentGame = _db.Games.FirstOrDefault(entry => entry.GameId == gameId); int[,] board = currentGame.TakeTurn(x, y, playerId); string boardJson = JsonConvert.SerializeObject(board); if (playerId == currentGame.P1Id) { currentGame.P2Board = boardJson; currentGame.CurrentPlayer = currentGame.P2Id; } else if (playerId == currentGame.P2Id) { currentGame.P1Board = boardJson; currentGame.CurrentPlayer = currentGame.P1Id; } currentGame.TurnCount++; _db.Entry(currentGame).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Turn", new { id = gameId })); }