Beispiel #1
0
        public IHttpActionResult RemoveReaction(ReactionDTO reactionDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Model state not valid. Check parameters"));
            }

            Post post = _context.Posts.SingleOrDefault(p => p.TimeStamp.Equals(reactionDTO.MessageTimeStamp));

            if (post != null && reactionDTO.SlackUserId != post.SlackUserId)
            {
                if (reactionDTO.Reaction.Equals("+1"))
                {
                    post.AddUpVotesToPost(-1);
                }
                if (reactionDTO.Reaction.Equals("-1"))
                {
                    post.AddDownVotesToPost(-1);
                }

                undoAddPointsToUsers(post, reactionDTO);
                _context.SaveChanges();
            }

            return(Ok());
        }