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) });
public static CastVoteCommand ForNoteGroup(int id, VoteMutationType mutation) => new CastVoteCommand(VoteEntityType.NoteGroup, id, mutation);
internal CastVoteCommand(VoteEntityType entityType, int id, VoteMutationType mutation) { this.EntityType = entityType; this.Id = id; this.Mutation = mutation; }
public VoteChange(string retroId, VoteModel vote, VoteMutationType mutation) { this.RetroId = retroId; this.Vote = vote; this.Mutation = mutation; }