Example #1
0
        private async Task <Unit> HandleNoteGroupVote(int noteGroupId, VoteMutationType mutationType, CancellationToken cancellationToken)
        {
            using IReturnDbContext dbContext = this._returnDbContext.CreateForEditContext();

            // Get
            NoteGroup noteGroup = await dbContext.NoteGroups.Include(x => x.Retrospective)
                                  .Include(x => x.Lane).FirstOrDefaultAsync(x => x.Id == noteGroupId, cancellationToken);

            if (noteGroup == null)
            {
                throw new NotFoundException(nameof(NoteGroup), noteGroupId);
            }

            NoteVote vote = await(mutationType switch
            {
                VoteMutationType.Added => this.HandleNoteGroupVoteAdd(noteGroup: noteGroup, dbContext: dbContext, cancellationToken: cancellationToken),
                VoteMutationType.Removed => this.HandleNoteGroupVoteRemove(noteGroup: noteGroup, dbContext: dbContext, cancellationToken: cancellationToken),
                _ => throw new InvalidOperationException("Invalid vote mutation type: " + mutationType)
            });
Example #2
0
 public static CastVoteCommand ForNoteGroup(int id, VoteMutationType mutation) => new CastVoteCommand(VoteEntityType.NoteGroup, id, mutation);
Example #3
0
 internal CastVoteCommand(VoteEntityType entityType, int id, VoteMutationType mutation)
 {
     this.EntityType = entityType;
     this.Id         = id;
     this.Mutation   = mutation;
 }
Example #4
0
 public VoteChange(string retroId, VoteModel vote, VoteMutationType mutation)
 {
     this.RetroId  = retroId;
     this.Vote     = vote;
     this.Mutation = mutation;
 }