public void Post([FromBody] GameVM value) { using (var session = _repository.Store.OpenSession()) { var game = new ChessGame() { BoardOrientation = value.boardorientation, Pgn = value.pgn, IsCurrent = false }; session.Store(game); session.SaveChanges(); } }
public void PostCurrent([FromBody] GameVM value) { ChessGame currentGame = null; using (var session = _repository.Store.OpenSession()) { var results = from game in session.Query <ChessGame>() where game.IsCurrent select game; currentGame = results.FirstOrDefault(); if (currentGame == null) { currentGame = new ChessGame(); session.Store(currentGame); } currentGame.BoardOrientation = value.boardorientation; currentGame.Pgn = value.pgn; currentGame.IsCurrent = true; session.SaveChanges(); } }