예제 #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));
        }