public IActionResult index() { var friends = _Friends.getMyFriends(HttpContext.Session.GetString("ID")).ToList(); var posts = _Post.LoadPosts(HttpContext.Session.GetString("ID")).ToList(); List <Post> Allpost; foreach (var item in friends) { Allpost = _Post.LoadPosts(item).ToList(); posts.AddRange(Allpost); Allpost.Clear(); } ViewData["UID"] = HttpContext.Session.GetString("ID"); return(View(posts.OrderByDescending(p => p.PostDate))); }
//addPost => user Can add new Post => بديهيات public IActionResult addPost(Post p) { p.PostDate = DateTime.Now; p.UserID = HttpContext.Session.GetString("ID"); _Post.addPost(p); var friends = _Friends.getMyFriends(HttpContext.Session.GetString("ID")).ToList(); var posts = _Post.LoadPosts(HttpContext.Session.GetString("ID")).ToList(); List <Post> Allpost; foreach (var item in friends) { Allpost = _Post.LoadPosts(item).ToList(); posts.AddRange(Allpost); Allpost.Clear(); } ViewData["UID"] = HttpContext.Session.GetString("ID"); return(PartialView("Posted", posts)); }