public CheckUniquePasswordHandler(ILogger logger, IThreadContextSessionProvider threadContextSessionProvider, IBotUserRepository botUserRepository) { _logger = logger; _threadContextSessionProvider = threadContextSessionProvider; _botUserRepository = botUserRepository; }
public GameRequestHandler( IThreadContextSessionProvider threadContextSessionProvider, IGameRepository gameRepository) { _threadContextSessionProvider = threadContextSessionProvider; _gameRepository = gameRepository; }
public ChangePlayerStateRequestHandler( IThreadContextSessionProvider threadContextSessionProvider, IPlayerRepository playerRepository) { _threadContextSessionProvider = threadContextSessionProvider; _playerRepository = playerRepository; }
public AuthorizeNewAccountRequestHandler(ILogger logger, IThreadContextSessionProvider threadContextSessionProvider, IBotUserRepository botUserRepository) { _logger = logger; _threadContextSessionProvider = threadContextSessionProvider; _botUserRepository = botUserRepository; }
public AddPlayerToGameRequestDialog(IEnumerable <ICommunicator> communicators, Guid userId, AddPlayerToGameRequest dialogData, ILogger logger, IMediator mediator, IThreadContextSessionProvider threadContextSessionProvider, IGameRepository gameRepository, IServiceConfiguration serviceConfiguration) : base(logger, communicators, userId, dialogData) { _mediator = mediator; _threadContextSessionProvider = threadContextSessionProvider; _gameRepository = gameRepository; _serviceConfiguration = serviceConfiguration; _hasDesicion = false; using (threadContextSessionProvider.CreateSessionScope()) { var games = gameRepository.ListBySpecification(new UndeletedEntities <Game>()).ToList(); games = games.Where(x => x.AcceptedPlayers.Count + x.RequestedPlayers.Count <serviceConfiguration.PlayersPerTeam * 2 && x.IsActive && x.DateTime> DateTime.Now .Add( serviceConfiguration .GameDeadline, serviceConfiguration .StartDayTime, serviceConfiguration .EndDayTime)) .OrderBy(x => x.DateTime) .Take(20).ToList(); if (!games.Any()) { Add($"Нет игр для добавления игроков"); } else { Add($"Введи номер игры, в которую хочешь добавить игроков:"); var gamesMessage = string.Join("\n", games.Select((x, index) => $"{index + 1}. Дата: {x.DateTime.ToString(DateTimeHelper.DateFormat)}")); Add(gamesMessage); Add((message, data) => { if (!int.TryParse(message, out var number) || (number < 1 && number > games.Count())) { throw new InvalidInputException($"Введи номер игры от 1 до {games.Count()}"); } data.GameId = games[number - 1].Id; var game = games[number - 1]; AddPlayerProcessingMessages(game.Id); return(data); }); } } }
public RegisterRequestHandler(ILogger logger, IThreadContextSessionProvider threadContextSessionProvider, IBotUserRepository botUserRepository) { _logger = logger; _threadContextSessionProvider = threadContextSessionProvider; _botUserRepository = botUserRepository; }
public PlayerStatusRequestHandler(ILogger logger, IThreadContextSessionProvider threadContextSessionProvider, IBotUserRepository botUserRepository, IPlayerRepository playerRepository) { _logger = logger; _threadContextSessionProvider = threadContextSessionProvider; _botUserRepository = botUserRepository; _playerRepository = playerRepository; }
public SetGameResultRequestHandler( IThreadContextSessionProvider threadContextSessionProvider, IPlayerRepository playerRepository, IGameRepository gameRepository) { _threadContextSessionProvider = threadContextSessionProvider; _playerRepository = playerRepository; _gameRepository = gameRepository; }
public PlayerGameAcceptanceTimeoutEventMetadataRequestHandler(IMediator mediator, IUserInteractionService userInteractionService, ICommunicatorFactory communicatorFactory, IThreadContextSessionProvider threadContextSessionProvider, IPlayerRepository playerRepository) { _mediator = mediator; _userInteractionService = userInteractionService; _communicatorFactory = communicatorFactory; _threadContextSessionProvider = threadContextSessionProvider; _playerRepository = playerRepository; }
public CancelGameRequestHandler( IThreadContextSessionProvider threadContextSessionProvider, IBotUserRepository botUserRepository, IScheduler scheduler, IGameRepository gameRepository, IUserInteractionService userInteractionService) { _threadContextSessionProvider = threadContextSessionProvider; _botUserRepository = botUserRepository; _scheduler = scheduler; _gameRepository = gameRepository; _userInteractionService = userInteractionService; }
public CancelGameRequestDialog(IEnumerable <ICommunicator> communicators, Guid userId, CancelGameRequest dialogData, ILogger logger, IMediator mediator, IThreadContextSessionProvider threadContextSessionProvider, IGameRepository gameRepository, IServiceConfiguration serviceConfiguration) : base(logger, communicators, userId, dialogData) { _mediator = mediator; _hasDecision = false; using (threadContextSessionProvider.CreateSessionScope()) { var games = gameRepository.ListBySpecification(new UndeletedEntities <Game>()).Where(x => x.IsActive && x.DateTime > DateTime.Now .Add( serviceConfiguration .GameDeadline, serviceConfiguration .StartDayTime, serviceConfiguration .EndDayTime)) .OrderBy(x => x.DateTime) .Take(20).ToList(); if (games.Count == 0) { Add($"Нет игр для отмены"); } else { Add($"Введи номер игры, которую хочешь отменить:"); var gamesMessage = string.Join("\n", games.Select((x, index) => $"{index + 1}. Дата: {x.DateTime.ToString(DateTimeHelper.DateFormat)}")); Add(gamesMessage); Add((message, data) => { if (!int.TryParse(message, out var number) || (number < 1 && number > games.Count())) { throw new InvalidInputException($"Введи номер игры от 1 до {games.Count()}"); } _hasDecision = true; data.GameId = games[number - 1].Id; return(data); }); } } }
public ScheduleGameRequestHandler(ILogger logger, IThreadContextSessionProvider threadContextSessionProvider, IBotUserRepository botUserRepository, IScheduler scheduler, IGameRepository gameRepository, IServiceConfiguration configuration) { _logger = logger; _threadContextSessionProvider = threadContextSessionProvider; _botUserRepository = botUserRepository; _scheduler = scheduler; _gameRepository = gameRepository; _configuration = configuration; }
public AddPlayerToGameRequestHandler( IThreadContextSessionProvider threadContextSessionProvider, IGameRepository gameRepository, IUserInteractionService userInteractionService, IPlayerRepository playerRepository, IServiceConfiguration serviceConfiguration, IScheduler scheduler) { _threadContextSessionProvider = threadContextSessionProvider; _gameRepository = gameRepository; _userInteractionService = userInteractionService; _playerRepository = playerRepository; _serviceConfiguration = serviceConfiguration; _scheduler = scheduler; }
public DistributionByTeamsEventMetadataRequestHandler( IServiceConfiguration serviceConfiguration, IThreadContextSessionProvider threadContextSessionProvider, IGameRepository gameRepository, IScheduler scheduler, IUserInteractionService userInteractionService, IBotUserRepository botUserRepository) { _serviceConfiguration = serviceConfiguration; _threadContextSessionProvider = threadContextSessionProvider; _gameRepository = gameRepository; _scheduler = scheduler; _userInteractionService = userInteractionService; _botUserRepository = botUserRepository; }
public PlayersCollectingDeadlineEventMetadataRequestHandler( IMediator mediator, IServiceConfiguration serviceConfiguration, IThreadContextSessionProvider threadContextSessionProvider, IGameRepository gameRepository, IScheduler scheduler, IUserInteractionService userInteractionService) { _mediator = mediator; _serviceConfiguration = serviceConfiguration; _threadContextSessionProvider = threadContextSessionProvider; _gameRepository = gameRepository; _scheduler = scheduler; _userInteractionService = userInteractionService; }
public PlayerGameDecisionRequestHandler( IServiceConfiguration serviceConfiguration, IThreadContextSessionProvider threadContextSessionProvider, IPlayerRepository playerRepository, IGameRepository gameRepository, IScheduler scheduler, IUserInteractionService userInteractionService, ICommunicatorFactory communicatorFactory, IMediator mediator) { _serviceConfiguration = serviceConfiguration; _threadContextSessionProvider = threadContextSessionProvider; _playerRepository = playerRepository; _gameRepository = gameRepository; _scheduler = scheduler; _userInteractionService = userInteractionService; _communicatorFactory = communicatorFactory; _mediator = mediator; }
public PrimaryCollectingEventMetadataRequestHandler( IMediator mediator, ILogger logger, IServiceConfiguration serviceConfiguration, IThreadContextSessionProvider threadContextSessionProvider, IPlayerRepository playerRepository, IGameRepository gameRepository, IScheduler scheduler, IUserInteractionService userInteractionService, ICommunicatorFactory communicatorFactory) { _mediator = mediator; _logger = logger; _serviceConfiguration = serviceConfiguration; _threadContextSessionProvider = threadContextSessionProvider; _playerRepository = playerRepository; _gameRepository = gameRepository; _scheduler = scheduler; _userInteractionService = userInteractionService; _communicatorFactory = communicatorFactory; }
public UserInteractionService( IDialogStorage dialogStorage, CommandFactory commandFactory, ILogger logger, IMediator mediator, IThreadContextSessionProvider threadContextSessionProvider, IBotUserRepository botUserRepository, IPlayerRepository playerRepository, IServiceConfiguration serviceConfiguration, IGameRepository gameRepository, ICommunicatorFactory communicatorFactory ) { _dialogStorage = dialogStorage; _commandFactory = commandFactory; _logger = logger; _mediator = mediator; _threadContextSessionProvider = threadContextSessionProvider; _botUserRepository = botUserRepository; _playerRepository = playerRepository; _serviceConfiguration = serviceConfiguration; _gameRepository = gameRepository; _communicatorFactory = communicatorFactory; }
public PlayerGameDecisionRequestDialog(IEnumerable <ICommunicator> communicators, Guid userId, PlayerGameDecisionRequest dialogData, ILogger logger, IMediator mediator, IThreadContextSessionProvider threadContextSessionProvider, IGameRepository gameRepository) : base(logger, communicators, userId, dialogData) { _mediator = mediator; using (threadContextSessionProvider.CreateSessionScope()) { var game = gameRepository.Get(dialogData.GameId); Add($"Играешь {game.DateTime}? (Ответь - \"да\" или \"нет\" или отмени диалог командой - /cancel. Если отменишь диалог, то принять решение можно немного позже, используя команды - /accept, /reject)"); Add((message, data) => { if (!message.CaseInsensitiveContains("да") && !message.CaseInsensitiveContains("нет")) { throw new InvalidInputException("Введи \"да\" или \"нет\""); } if (message.CaseInsensitiveContains("да")) { data.Decision = true; } if (message.CaseInsensitiveContains("нет")) { data.Decision = false; } return(data); }); Add($"Твой ответ учтен"); } }
public SessionScope(IThreadContextSessionProvider sessionProvider) { _sessionProvider = sessionProvider; Session = _sessionProvider.OpenSession(); }
public PlayerGameDeferedDecisionRequestDialog(IEnumerable <ICommunicator> communicators, Guid userId, PlayerGameDecisionRequest dialogData, ILogger logger, IMediator mediator, IThreadContextSessionProvider threadContextSessionProvider, IGameRepository gameRepository, IServiceConfiguration serviceConfiguration, bool decision) : base(logger, communicators, userId, dialogData) { _hasDecision = false; _mediator = mediator; using (threadContextSessionProvider.CreateSessionScope()) { var games = gameRepository.ListBySpecification(new UndeletedEntities <Game>()).ToList(); games = games.Where(x => x.IsActive && x.DateTime > DateTime.Now .Add( serviceConfiguration .GameDeadline, serviceConfiguration .StartDayTime, serviceConfiguration .EndDayTime)) .OrderBy(x => x.DateTime) .ToList(); games = decision ? games.Where(x => x.RequestedPlayers.Any(y => y.Player.User.Id == userId)).Take(20).ToList() : games.Where(x => x.AcceptedPlayers.Any(y => y.User.Id == userId)).Take(20).ToList(); if (games.Count == 0) { Add($"Нет игр, по которым ты можешь выбрать решение"); } else { var decisionMessage = decision ? "которую хочешь принять" : "от которой хочешь отказаться"; Add($"Введи номер игры, {decisionMessage}:"); var gamesMessage = string.Join("\n", games.Select((x, index) => $"{index + 1}. Дата: {x.DateTime.ToString(DateTimeHelper.DateFormat)}")); Add(gamesMessage); Add((message, data) => { if (!int.TryParse(message, out var number) || (number < 1 && number > games.Count())) { throw new InvalidInputException($"Введи номер игры от 1 до {games.Count()}"); } _hasDecision = true; data.GameId = games[number - 1].Id; data.Decision = decision; data.PlayerId = games[number - 1].AcceptedPlayers.First(x => x.User.Id == userId).Id; return(data); }); } } }
public SetGameResultRequestDialog(IEnumerable <ICommunicator> communicators, Guid userId, SetGameResultRequest dialogData, ILogger logger, IMediator mediator, IThreadContextSessionProvider threadContextSessionProvider, IGameRepository gameRepository) : base(logger, communicators, userId, dialogData) { _mediator = mediator; _threadContextSessionProvider = threadContextSessionProvider; _gameRepository = gameRepository; using (threadContextSessionProvider.CreateSessionScope()) { var games = gameRepository.ListBySpecification(new UndeletedEntities <Game>()) .Where(x => DateTime.Now > x.DateTime && !x.ResultSet).ToList(); if (!games.Any()) { Add($"Нет игр для внесения результата"); } else { var startMessage = $"Игры без результатов:\n"; startMessage += string.Join("\n", games.Select((x, index) => $"{index + 1}. {x.DateTime}")); Add(startMessage); Add("Введи номер игры, по которой хочешь внести результат"); Add((message, data) => { if (!int.TryParse(message, out var number) || (number < 1 && number > games.Count())) { throw new InvalidInputException($"Введи номер игры от 1 до {games.Count()}"); } data.GameId = games[number - 1].Id; return(data); }); Add("Введи нразницу голов:"); var goalDifference = 0; Add((message, data) => { if (!int.TryParse(message, out var number) || number < 0) { throw new InvalidInputException($"Введи положительное число"); } data.GoalDifference = number; goalDifference = number; if (goalDifference == 0) { data.TeamWinningNumber = 1; } else { SetWinnerDialog(data.GameId); } return(data); }); } } }