/// <summary> /// Before the update in DB, check it the data is consistant. /// </summary> /// <param name="nPins"> Number of pins knocked. </param> private void tryUpdateModel(int nPins) { string scoreString = DbFileController.Load(); List <int> rolls = Tools.Parser.GetIntegers(scoreString); Game game = new Game(rolls); // Throw an exception if the model is invalid. game.PinsKnocked(nPins); }
private ActionResult <APIGameResults> scoresController() { string scoreString = DbFileController.Load(); List <int> rolls = Tools.Parser.GetIntegers(scoreString); Game game = new Game(rolls); var apiResults = new APIGameResults(game.GetFramesScore().ToArray()); return(apiResults); }
private void playController(int nPinsKnocked) { if (!System.IO.File.Exists(DbFileController.filePath)) { throw new ApplicationException(ErrorMessage.GAME_NOT_STARTED); } // Check if the model is consistant before saving. this.tryUpdateModel(nPinsKnocked); DbFileController.Save(nPinsKnocked); }
public ActionResult Start() { DbFileController.StartDB(); return(Ok("Game started")); }