示例#1
0
        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();
        }
示例#2
0
 public CommentKarma(User author, Comment comment, KarmaValue value)
     : base(author, value)
 {
     SetComment(comment);
 }
示例#3
0
 public EntryKarma(User author, Entry entry, KarmaValue value)
     : base(author, value)
 {
     SetEntry(entry);
 }
示例#4
0
 public void SetValue(KarmaValue value)
 {
     Value = value;
 }
示例#5
0
 public KarmaBase(User author, KarmaValue value)
 {
     SetAuthor(author);
     SetValue(value);
 }
 async void OnChangeVote(KarmaValue karmaValue)
 {
     await OnChangeVote(KarmaService.VoteFor.Comment, karmaValue, _commentData.Id);
 }