Пример #1
0
        /// <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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
 public ActionResult Start()
 {
     DbFileController.StartDB();
     return(Ok("Game started"));
 }