Esempio n. 1
0
        public IHttpActionResult GetLiteMeme(string id)
        {
            MemeLiteModel meme = this.GetMemeLite(id);

            if (meme == null)
            {
                return(NotFound());
            }

            return(Ok(meme));
        }
Esempio n. 2
0
        public IHttpActionResult GetMemeReplies(string id, int skip, int take)
        {
            IMeme meme           = repository.GetMeme(id);
            int   fullReplyCount = 0;

            if (meme == null)
            {
                return(NotFound());
            }

            List <MemeLiteModel> replies = new List <MemeLiteModel>();

            // No replies no list
            if (meme.ReplyIds != null)
            {
                // Gwet the full count of all replies (even if not all are being returned)
                fullReplyCount = meme.ReplyIds.Count;

                // Get the meme ids of the relevent replies
                IEnumerable <IReply> memeReplies = meme.ReplyIds
                                                   .OrderByDescending(x => x.TrendScore)
                                                   .ThenByDescending(y => y.DateCreated)
                                                   .Skip(skip)
                                                   .Take(take);
                // Create the list of reply memes
                foreach (IReply reply in memeReplies)
                {
                    MemeLiteModel replyMeme = this.GetMemeLite(reply.Id);
                    if (replyMeme != null)
                    {
                        replies.Add(replyMeme);
                    }
                }
            }

            return(Ok(new { fullReplyCount, replies }));
        }