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); } }
public async Task <ActionResult <ReactionState> > GetState(ReactionTarget targetType, int targetId) { var state = await _reactionService.GetState(targetType, targetId, Account.Id); return(Ok(state)); }
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)); }
public async Task <ActionResult <IEnumerable <ReactionResponse> > > GetAllByTargetId(ReactionTarget targetType, int targetId) { var reactions = await _reactionService.GetAllByTargetId(targetType, targetId); return(Ok(reactions)); }