public async Task <GetEstimationsQueryResponse> Handle(GetEstimationsQuery request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } using IPokerTimeDbContext dbContext = this._dbContextFactory.CreateForEditContext(); UserStory userStory = await dbContext.UserStories. Where(x => x.Session.UrlId.StringId == request.SessionId && x.Id == request.UserStoryId). FirstOrDefaultAsync(cancellationToken); if (userStory == null) { throw new NotFoundException(nameof(UserStory), request.UserStoryId); } List <Estimation> estimations = await dbContext.Estimations .Include(x => x.Participant) .Include(x => x.Symbol) .Where(x => x.UserStoryId == userStory.Id) .ToListAsync(cancellationToken); var response = new GetEstimationsQueryResponse( this._mapper.Map <List <EstimationModel> >(estimations) ); return(response); }
public JoinPokerSessionCommandHandler(IPokerTimeDbContext pokerTimeDbContext, ICurrentParticipantService currentParticipantService, IMediator mediator, IMapper mapper) { this._pokerTimeDbContext = pokerTimeDbContext; this._currentParticipantService = currentParticipantService; this._mediator = mediator; this._mapper = mapper; }
public async Task PokerLobby_ShowsCards_OnAdvancingSession() { // Given await Task.WhenAll( Task.Run(() => this.Join(this.Client1, true)), Task.Run(() => this.Join(this.Client2, false)) ); this.WaitNavigatedToLobby(); // When this.Client1.WorkflowContinueButton.Click(); // Then IPokerTimeDbContext dbContext = this.ServiceScope.ServiceProvider.GetRequiredService <IPokerTimeDbContext>(); Session currentSession = await dbContext.Sessions.FindBySessionId(this.SessionId, CancellationToken.None); var dbCardIds = dbContext.Symbols.Where(x => x.SymbolSetId == currentSession.SymbolSetId).Select(x => x.Id).ToList(); this.MultiAssert(client => { Assert.That(() => client.CardChooserElement, Has.Property(nameof(IWebElement.Displayed)).EqualTo(true).Retry(), "The card chooser is not displayed"); Assert.That(() => { return(client.CardChooser.Cards.Select(x => x.Id)); }, Is.EquivalentTo(dbCardIds).And.Not.Empty.Retry(), "Not all poker cards are shown"); Assert.That(() => client.CardChooser.Cards.All(x => x.IsEnabled == false), Is.True.Retry(), "Some cards are interactable in this stage, which shouldn't be the case"); }); }
public async Task <GetEstimationsOverviewQueryResponse> Handle(GetEstimationsOverviewQuery request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } using IPokerTimeDbContext dbContext = this._dbContextFactory.CreateForEditContext(); Session session = await dbContext.Sessions.FindBySessionId(request.SessionId, cancellationToken); if (session == null) { throw new NotFoundException(nameof(Session), request.SessionId); } List <UserStory> userStories = await dbContext.UserStories.Where(x => x.SessionId == session.Id). OrderBy(x => x.Id). Include(x => x.Estimations). ThenInclude(x => x.Symbol). Include(x => x.Estimations). ThenInclude(x => x.Participant). ToListAsync(cancellationToken); return(new GetEstimationsOverviewQueryResponse( this._mapper.Map <IEnumerable <UserStoryEstimation> >(userStories) )); }
public CreatePokerSessionCommandHandler(IPokerTimeDbContext pokerTimeDbContext, IPassphraseService passphraseService, ISystemClock systemClock, IUrlGenerator urlGenerator, ILogger <CreatePokerSessionCommandHandler> logger) { this._pokerTimeDbContext = pokerTimeDbContext; this._passphraseService = passphraseService; this._systemClock = systemClock; this._urlGenerator = urlGenerator; this._logger = logger; }
public async Task <GetSymbolSetsQueryResponse> Handle(GetSymbolSetsQuery request, CancellationToken cancellationToken) { using IPokerTimeDbContext dbContext = this._dbContextFactory.CreateForEditContext(); SymbolSetModel[] symbolSets = this._mapper.Map <SymbolSetModel[]>( await dbContext.SymbolSets.Include(x => x.Symbols).OrderBy(x => x.Id).ToListAsync(cancellationToken)); return(new GetSymbolSetsQueryResponse(symbolSets)); }
public async Task PokerLobby_ShowsInteractableCards_OnEstimationSession() { await this.SetCurrentUserStory(); await this.SetRetrospective(s => s.CurrentStage = SessionStage.Discussion); // Given await Task.WhenAll( Task.Run(() => this.Join(this.Client1, true)), Task.Run(() => this.Join(this.Client2, false)) ); this.WaitNavigatedToLobby(); // When this.Client1.InvokeContinueWorkflow(); // Then IPokerTimeDbContext dbContext = this.ServiceScope.ServiceProvider.GetRequiredService <IPokerTimeDbContext>(); Session currentSession = await dbContext.Sessions.FindBySessionId(this.SessionId, CancellationToken.None); var dbCardIds = dbContext.Symbols.Where(x => x.SymbolSetId == currentSession.SymbolSetId).Select(x => x.Id).ToList(); this.MultiAssert(client => { Assert.That(() => client.CardChooserElement, Has.Property(nameof(IWebElement.Displayed)).EqualTo(true).Retry(), "The card chooser is not displayed"); Assert.That(() => client.EstimationOverviewElement, Has.Property(nameof(IWebElement.Displayed)).EqualTo(true).Retry(), "The estimation overview is not displayed"); Assert.That(() => { return(client.CardChooser.Cards.Select(x => x.Id)); }, Is.EquivalentTo(dbCardIds).And.Not.Empty.Retry(), "Not all poker cards are shown"); Assert.That(() => client.CardChooser.Cards.All(x => x.IsEnabled == true), Is.True.Retry(), "Some cards are not interactable in this stage, all should be interactable"); }); }
public GetJoinPokerSessionInfoQueryHandler(IPokerTimeDbContext dbContext, ILogger <GetJoinPokerSessionInfoQueryHandler> logger) { this._dbContext = dbContext; this._logger = logger; }
public GetParticipantQueryHandler(IPokerTimeDbContext pokerTimeDbContext, IMapper mapper) { this._pokerTimeDbContext = pokerTimeDbContext; this._mapper = mapper; }
public GetAvailablePredefinedParticipantColorsQueryHandler(IPokerTimeDbContext dbContext, IMapper mapper) { this._dbContext = dbContext; this._mapper = mapper; }
public BaseDataSeeder(IPokerTimeDbContext pokerTimeDbContext) { this._pokerTimeDbContext = pokerTimeDbContext; }
public SeedBaseDataCommandHandler(IPokerTimeDbContext pokerTimeDbContext) { this._pokerTimeDbContext = pokerTimeDbContext; }
public SessionStatusMapper(IPokerTimeDbContext pokerTimeDbContext, IMapper mapper) { this._mapper = mapper; this._pokerTimeDbContext = pokerTimeDbContext; }
public GetSessionStatusQueryHandler(IPokerTimeDbContext pokerTimeDbContext, ISessionStatusMapper mapper) { this._pokerTimeDbContext = pokerTimeDbContext; this._mapper = mapper; }
public GetSymbolsQueryHandler(IPokerTimeDbContext pokerTimeDbContext, IMapper mapper) { this._pokerTimeDbContext = pokerTimeDbContext; this._mapper = mapper; }
public InitiateDiscussionStageCommandHandler(IPokerTimeDbContext pokerTimeDbContext, ISessionStatusUpdateDispatcher sessionStatusUpdateDispatcher) : base(pokerTimeDbContext, sessionStatusUpdateDispatcher) { }
public RejoinPokerSessionCommandHandler(IPokerTimeDbContext pokerTimeDbContext, ICurrentParticipantService currentParticipantService) { this._pokerTimeDbContext = pokerTimeDbContext; this._currentParticipantService = currentParticipantService; }
public async Task <Unit> Handle(PlayCardCommand request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } using IPokerTimeDbContext dbContext = this._dbContextFactory.CreateForEditContext(); Session session = await dbContext.Sessions.FindBySessionId(request.SessionId, cancellationToken); if (session == null) { throw new NotFoundException(nameof(Session), request.SessionId); } UserStory userStory = await dbContext.UserStories.FirstOrDefaultAsync(x => x.Session.UrlId.StringId == request.SessionId && x.Id == request.UserStoryId, cancellationToken); if (userStory == null) { throw new NotFoundException(nameof(UserStory), request.UserStoryId); } Symbol desiredSymbol = await dbContext.Symbols.FirstOrDefaultAsync(x => x.Id == request.SymbolId, cancellationToken); if (desiredSymbol == null) { throw new NotFoundException(nameof(Symbol), request.SymbolId); } if (desiredSymbol.SymbolSetId != session.SymbolSetId) { throw new InvalidOperationException($"The chosen symbol #{request.SymbolId} is not part of symbol set #{session.SymbolSetId}"); } CurrentParticipantModel currentParticipantInfo = await this._currentParticipantService.GetParticipant(); // Add or update estimation Estimation estimation = await dbContext.Estimations .Include(x => x.Participant) .Where(x => x.UserStory.Session.UrlId.StringId == session.UrlId.StringId) .FirstOrDefaultAsync(x => x.UserStory.Id == userStory.Id && x.ParticipantId == currentParticipantInfo.Id, cancellationToken); if (estimation == null) { estimation = new Estimation { ParticipantId = currentParticipantInfo.Id, Participant = dbContext.Participants.First(x => x.Id == currentParticipantInfo.Id), UserStory = userStory, Symbol = desiredSymbol }; dbContext.Estimations.Add(estimation); } else { estimation.Symbol = desiredSymbol; } await dbContext.SaveChangesAsync(cancellationToken); var estimationNotification = new EstimationGivenNotification( session.UrlId.StringId, this._mapper.Map <EstimationModel>(estimation) ); await this._mediator.Publish(estimationNotification, cancellationToken); return(Unit.Value); }