public ActionResult <List <ReactionsDto> > GetAllReactions([FromHeader(Name = "CommunicationKey")] string key) { var reactions = reactionRepository.GetReactions(); if (reactions == null) { return(StatusCode(StatusCodes.Status404NotFound, "There is no reactions.")); } return(Ok(mapper.Map <List <ReactionsDto> >(reactions))); }
public IActionResult Details(int id) { var post = _postRepository.GetPublishedPostById(id); int userId = GetCurrentUserProfileId(); if (post == null) { post = _postRepository.GetUserPostById(id, userId); if (post == null) { return(NotFound()); } } List <Reaction> reactions = _reactionRepository.GetReactions(); List <PostReaction> postReactions = _postReactionRepository.GetPostReactionsByPostId(id); List <Subscription> mySubscriptions = _subscriptionRepository.GetUserSubscriptions(userId); PostDetailsViewModel vm = new PostDetailsViewModel(); vm.Post = post; vm.AllReactions = reactions; vm.AllPostReactions = postReactions; vm.Tags = _tagRepository.GetTagPostById(id); foreach (Subscription subscription in mySubscriptions) { if (subscription.ProviderUserProfileId == post.UserProfileId) { vm.Subscribed = true; vm.SubscriptionId = subscription.Id; } } return(View(vm)); }