public async Task <IActionResult> GetPosts() { var posts = await _postManager.GetAllPosts(); var response = _mapper.Map <IEnumerable <PostResponse> >(posts); return(Ok(response)); }
public async Task <IViewComponentResult> InvokeAsync(int blogId) { var posts = await _postManager.GetAllPosts(blogId); var models = _mapper.Map <IList <PostDetailsViewModel> >(posts); return(View("Posts", models)); }
public async Task <List <Post> > Get() { return(await _posts.GetAllPosts()); }
public ListResultDto <PostOutput> GetPostsUsingTag(string tag) { if (string.IsNullOrWhiteSpace(tag)) { return(new ListResultDto <PostOutput>(ObjectMapper.Map <List <PostOutput> >(_postManager.GetAllPosts()))); } return(new ListResultDto <PostOutput>(ObjectMapper.Map <List <PostOutput> >(_postManager.GetAllPosts().Where(h => h.Tags.Split().Contains(tag))))); }
public ActionResult GetAllPosts(int pageNo, string searcText, int entries) { var data = postManager.GetAllPosts(pageNo, searcText, entries); return(Json(data, JsonRequestBehavior.AllowGet)); }
private void getPosts(UserDTO user) { List <UserDTOn> friends = _userManager.GetFriends(_userManager.GetUserByMongoId(user.UserId).userId); List <PostDTO> allPosts = _postManager.GetAllPosts(); List <PostDTO> post = new List <PostDTO>(); foreach (PostDTO p in allPosts) { foreach (UserDTOn u in friends) { if (_userManager.GetUserByNeoId(u.userId).UserId == p.UserID) { post.Add(p); } } } if (post == null) { Console.WriteLine("List of posts is empty, your friends don't write anything:("); } else { showPosts(post); int step; bool flag = true; while (flag) { Console.WriteLine("\nYou can using postId to: " + "\n1. Add comment." + "\n2. Like." + "\n0. Exit." + "\nSo, enter postId : "); try { step = Convert.ToInt32(Console.ReadLine()); int id; switch (step) { case 1: id = Convert.ToInt32(Console.ReadLine()); addComment(user, post, id); break; case 2: id = Convert.ToInt32(Console.ReadLine()); foreach (PostDTO p in post) { if (id == p.PostId) { _postManager.Like(id); } } break; case 0: flag = false; break; default: throw new Exception("You've inputed wrong data."); } } catch (Exception e) { Console.WriteLine(e); } } } }
public IEnumerable <Post> Get() { //return Ok(); return(_postManager.GetAllPosts()); }