コード例 #1
0
        public async Task <ReactionState> GetState(ReactionTarget targetType, int targetId, int ownerId)
        {
            var reaction = await _context.Reactions.Where(reaction =>
                                                          reaction.Target == targetType &&
                                                          reaction.TargetId == targetId &&
                                                          reaction.OwnerId == ownerId).CountAsync();

            var reactionState = new ReactionState
            {
                IsCreated = 0
            };

            if (reaction != 0)
            {
                reactionState.IsReactedByThisUser = true;
                reactionState.IsCreated           = 1;
                return(reactionState);
            }
            else
            {
                return(reactionState);
            }
        }
コード例 #2
0
        public async Task <ActionResult <ReactionState> > GetState(ReactionTarget targetType, int targetId)
        {
            var state = await _reactionService.GetState(targetType, targetId, Account.Id);

            return(Ok(state));
        }
コード例 #3
0
        public async Task <IEnumerable <ReactionResponse> > GetAllByTargetId(ReactionTarget targetType, int targetId)
        {
            var reactions = await _context.Reactions.Where(reaction => reaction.Target == targetType && reaction.TargetId == targetId).ToListAsync();

            return(_mapper.Map <List <ReactionResponse> >(reactions));
        }
コード例 #4
0
        public async Task <ActionResult <IEnumerable <ReactionResponse> > > GetAllByTargetId(ReactionTarget targetType, int targetId)
        {
            var reactions = await _reactionService.GetAllByTargetId(targetType, targetId);

            return(Ok(reactions));
        }