public IActionResult Search(SearchPostOptions options) { var posts = postService .SearchPost(options) .ToList(); if (!posts.Any()) { return(NotFound()); } if (posts == null) { return(BadRequest()); } return(Json(posts)); }
public IQueryable <Posts> SearchPost( SearchPostOptions options) { if (options == null) { return(null); } var query = context_ .Set <Posts>() .AsQueryable(); if (options.PostId != null) { query = query.Where(p => p.PostsId == options.PostId.Value); } query = query.Take(500); return(query); }