Пример #1
0
        public async Task <IActionResult> RefreshGame(int gameId, int playerId)
        {
            Game game = await gamesRepository.GetGameAsync(gameId);

            dynamic responseData = new ExpandoObject();

            responseData.game = game;
            StorageItem newGameCreatorItem = storage.GetItem(gameId, SessionKeys.NewGameCreator);

            if (newGameCreatorItem != null && !newGameCreatorItem.IsReadedByPlayerId(playerId))
            {
                Player newGameCreator = game.Players.First(p => p.IsGameCreator);
                if (newGameCreator != null)
                {
                    newGameCreatorItem.MarkAsReadedByPlayerId(playerId);
                    responseData.newGameCreator   = true;
                    responseData.newGameCreatorId = newGameCreator.Id;
                    storage.TryRemoveItem(gameId, SessionKeys.NewGameCreator);
                }
            }

            return(new OkObjectResult(responseData));
        }