public IActionResult GetFollowedUsersPosts() { if (_workContext.CurrentCustomer.IsRegistered()) { var posts = _followRepository.GetFollowedPosts(_workContext.CurrentCustomer.Id); var users = _followRepository.GetFollowedUsers(_workContext.CurrentCustomer.Id); var modelList = new List <PostModel>(); foreach (var follow in posts) { var p = _postService.GetPost((int)follow.PostId, ""); modelList.Add(new PostModel { CategoryId = p.CategoryId, CategoryName = p.Category.Name, Text = p.Text, Id = p.Id, Title = p.Title, City = p.City.ArName, DateCreated = p.DateCreated, Photo = p.Z_Harag_Photo.Select(ppp => ppp.Url).FirstOrDefault(), DateUpdated = p.DateUpdated, IsDispayed = p.IsDispayed, PostOwner = p.Customer.Username, CreationTime = (DateTime)follow.CreatedTime }); } var modelUsersList = new List <UserModel>(); foreach (var follow in users) { var u = _customerContext.GetCustomerById((int)follow.FollowedId); modelUsersList.Add(new UserModel { Phone = u.Mobile, Id = u.Id, Username = u.Username, CreationTime = (DateTime)follow.CreatedTime }); } var generalModel = new UserOutputModel { Posts = modelList, Users = modelUsersList }; return(View("~/Themes/Pavilion/Views/Harag/Follow/Follow.cshtml", generalModel)); } else { return(Redirect("Login")); } }