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>()); }
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); }
public ReadPostVM Get([FromQuery] PagingParamsVM pagingParams) { return(_postService.GetAllPosts(pagingParams)); }