コード例 #1
0
        public async Task Execute()
        {
            Console.WriteLine($"{nameof(NotificationSenderJob)} Job starting run");

            await _notificationHandler.SendNotificationAsync();

            Console.WriteLine($"{nameof(NotificationSenderJob)} Job ending run");
        }
コード例 #2
0
        public async Task <(MyChessGame?Game, HandlerError?Error)> CreateGameAsync(AuthenticatedUser authenticatedUser, MyChessGame game)
        {
            var opponentID = game.Players.Black.ID;
            var opponent   = await GetUserByUserIDAsync(opponentID);

            if (opponent == null)
            {
                return(null, new HandlerError()
                {
                    Instance = LoggingEvents.CreateLinkToProblemDescription(LoggingEvents.GameHandlerOpponentNotFound),
                    Status = (int)HttpStatusCode.NotFound,
                    Title = "User not found",
                    Detail = "For some reason your opponent could not be found"
                });
            }

            var user = await GetOrCreateUserAsync(authenticatedUser);

            game.ID = Guid.NewGuid().ToString("D");
            game.Players.White.ID = user.UserID;
            var data = _compactor.Compact(game);

            // TODO: Validate game data
            var comment = game.Moves[0].Comment;

            await _context.UpsertAsync(TableNames.GamesWaitingForYou, new GameEntity
            {
                PartitionKey = opponentID,
                RowKey       = game.ID,
                Data         = data
            });

            await _context.UpsertAsync(TableNames.GamesWaitingForOpponent, new GameEntity
            {
                PartitionKey = user.UserID,
                RowKey       = game.ID,
                Data         = data
            });

            await _notificationHandler.SendNotificationAsync(opponentID, game.ID, comment);

            return(game, null);
        }