Пример #1
0
    public IEnumerable <NewsItemVM> Get([ModelBinder(typeof(PaginationModelBinder))] PagingParamsVM pegination)
    {
        //Validate(pegination); //if I call this explicitly ModelState.IsValid is set correctly.
        var valid = ModelState.IsValid;     //this is always true

        return(Enumerable.Empty <NewsItemVM>());
    }
Пример #2
0
        public ReadPostVM GetAllPosts(PagingParamsVM pagingParams)
        {
            var dbPosts = dbContext.Posts
                          .OrderByDescending(x => x.PostDate)
                          .Skip((pagingParams.PageIndex) * pagingParams.PageSize)
                          .Take(pagingParams.PageSize).ToList();

            var postsCount = dbContext.Posts.Count();

            ReadPostVM posts = new ReadPostVM();

            posts.lstPosts   = dbPosts;
            posts.PostsCount = postsCount;

            return(posts);
        }
Пример #3
0
 public ReadPostVM Get([FromQuery] PagingParamsVM pagingParams)
 {
     return(_postService.GetAllPosts(pagingParams));
 }