public JsonNetResult GetPlayerGameById(int id)
        {
            var playerGameById = new PlayerGame();

            try
            {
                var repo = new PlayerGameRepository();
                playerGameById = repo.GetPlayerGameById(id);
            }
            catch (Exception)
            {
                throw;
            }

            return(new JsonNetResult(new
            {
                Data = playerGameById
            }, JsonRequestBehavior.DenyGet));
        }
        public JsonNetResult DeletePlayerGameById(int id)
        {
            string errorMessage = string.Empty;

            try
            {
                var repo = new PlayerGameRepository();
                var playerGameToDelete = repo.GetPlayerGameById(id);
                repo.RemovePlayerGame(playerGameToDelete);
            }
            catch (Exception e)
            {
                errorMessage = e.Message;
            }

            return(new JsonNetResult(new
            {
                ErrorMessage = errorMessage
            }, JsonRequestBehavior.DenyGet));
        }
        public JsonNetResult UpdatePlayerGame(PlayerGame playerGame)
        {
            string errorMessage = string.Empty;

            try
            {
                var repo           = new PlayerGameRepository();
                var playerToUpdate = repo.GetPlayerGameById(playerGame.PlayerGameId);
                playerToUpdate.GameId   = playerGame.Game.GameId;
                playerToUpdate.PlayerId = playerGame.Player.PlayerId;
                repo.SaveChanges();
            }
            catch (Exception e)
            {
                errorMessage = e.Message;
            }

            return(new JsonNetResult(new
            {
                ErrorMessage = errorMessage
            }, JsonRequestBehavior.DenyGet));
        }