Exemplo n.º 1
0
        private PlayedGame CreateTestPlayedGame(
            int gameDefinitionId,
            List <Player> players,
            List <int> correspondingPlayerRanks,
            ApplicationUser currentUser,
            IPlayedGameCreator playedGameCreator)
        {
            List <PlayerRank> playerRanks = new List <PlayerRank>();

            for (int i = 0; i < players.Count(); i++)
            {
                playerRanks.Add(new PlayerRank()
                {
                    PlayerId = players[i].Id,
                    GameRank = correspondingPlayerRanks[i]
                });
            }

            NewlyCompletedGame newlyCompletedGame = new NewlyCompletedGame()
            {
                GameDefinitionId = gameDefinitionId,
                PlayerRanks      = playerRanks,
            };

            return(playedGameCreator.CreatePlayedGame(newlyCompletedGame, TransactionSource.WebApplication, currentUser));
        }
Exemplo n.º 2
0
        public HttpResponseMessage RecordPlayedGame([FromBody] PlayedGameMessage playedGameMessage, [FromUri] int gamingGroupId)
        {
            var newlyCompletedGame = BuildNewlyPlayedGame(playedGameMessage);

            PlayedGame playedGame = playedGameCreator.CreatePlayedGame(newlyCompletedGame, TransactionSource.RestApi, CurrentUser);
            var        newlyRecordedPlayedGameMessage = new NewlyRecordedPlayedGameMessage
            {
                PlayedGameId = playedGame.Id
            };

            return(Request.CreateResponse(HttpStatusCode.OK, newlyRecordedPlayedGameMessage));
        }
Exemplo n.º 3
0
        public virtual ActionResult Create(NewlyCompletedGame newlyCompletedGame, ApplicationUser currentUser)
        {
            if (ModelState.IsValid)
            {
                playedGameCreator.CreatePlayedGame(newlyCompletedGame, TransactionSource.WebApplication, currentUser);

                return(new RedirectResult(Url.Action(MVC.GamingGroup.ActionNames.Index, MVC.GamingGroup.Name)
                                          + "#" + GamingGroupController.SECTION_ANCHOR_RECENT_GAMES));
            }

            return(Create(currentUser));
        }