コード例 #1
0
 public IEnumerable <PostModel> Posts([FromUri] int page = 1)
 {
     if (page > 0)
     {
         // paging
         int skip = (page - 1) * MAX_POST_COUNT;
         // posts
         List <PostModel> posts = (from p in _repo.Query <Post>()
                                   orderby p.Created descending
                                   select new PostModel
         {
             Id = p.PostId,
             Title = p.Title,
             ImageUrl = p.ImageUrl,
             SourceUrl = "http://www.reddit.com/" + p.RedditId
         }).Skip(skip).Take(MAX_POST_COUNT).ToList();
         // comments
         foreach (var post in posts)
         {
             post.Comments = (from c in _repo.Query <Comment>()
                              where c.Post.PostId == post.Id
                              select c.Text).ToList();
         }
         return(posts);
     }
     return(null);
 }
コード例 #2
0
        public IEnumerable <TagModel> Tags()
        {
            var tags = from t in _repo.Query <Tag>()
                       select new TagModel
            {
                Id   = t.TagId,
                Name = t.Name
            };

            return(tags.ToList());
        }
コード例 #3
0
ファイル: CSharpController.cs プロジェクト: anttieskola/ae
        public ActionResult Index()
        {
            var model = from s in _repo.Query <Snipplet>()
                        where s.Tags.Any(t => t.TagId == CsTagId)
                        orderby s.Headline
                        select new CSharpSnippletListItem {
                Id = s.SnippletId, Headline = s.Headline
            };

            return(View(model));
        }
コード例 #4
0
 public ActionResult ReadingView(int?id = null)
 {
     if (id != null)
     {
         var article = (from a in _repo.Query <Article>()
                        where a.ArticleId == (int)id
                        select new ArticleModel
         {
             Id = a.ArticleId,
             Title = a.Title,
             Description = a.Description,
             Content = a.Content,
             ImageUrl = a.ImageUrl,
             SourceUrl = a.SourceUrl,
             Date = a.Date
         }).FirstOrDefault();
         if (article != null)
         {
             return(View(article as ArticleModel));
         }
     }
     return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
 }