public async Task GiveKarmaAsync(string authorId, string itemId, KarmaValue value) { var karma = await FindCommentKarmaAsync(authorId, itemId); if (karma is null) { var user = await dbContext.Users.FindAsync(authorId); var comment = await dbContext.Comments.FindAsync(itemId); karma = new CommentKarma(user, comment, value); await dbContext.CommentKarma.AddAsync(karma); } else { if (karma.Author.Id != authorId) { throw new ApiException("Wrong author!"); } karma.SetValue(value); } await dbContext.SaveChangesAsync(); }
public CommentKarma(User author, Comment comment, KarmaValue value) : base(author, value) { SetComment(comment); }
public EntryKarma(User author, Entry entry, KarmaValue value) : base(author, value) { SetEntry(entry); }
public void SetValue(KarmaValue value) { Value = value; }
public KarmaBase(User author, KarmaValue value) { SetAuthor(author); SetValue(value); }
async void OnChangeVote(KarmaValue karmaValue) { await OnChangeVote(KarmaService.VoteFor.Comment, karmaValue, _commentData.Id); }