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")); } }
public IActionResult Profile() { if (!_workContext.CurrentCustomer.IsRegistered()) { return(Redirect("Login")); } var result = _workContext.CurrentCustomer; ViewBag.SameUser = true; ViewBag.CanRateOtherUsers = false; var posts = _postService.GetCurrentUserPosts(result.Id, PagingParams).Select(p => 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(), //Rate = p.Rate, DateUpdated = p.DateUpdated, IsDispayed = p.IsDispayed, PostOwner = p.Customer.Username, PostOwnerFullName = p.Customer.GetFullName() }).ToList(); var model = new ProfileModel { DownRating = _rateRepository.GetUserDownRates(result.Id).Count, UpRating = _rateRepository.GetUserUpRates(result.Id).Count, FollowerCount = _followRepository.GetFollowedUsers(result.Id).Count, LastSeen = result.LastActivityDateUtc, Posts = posts, MemberSince = result.CreatedOnUtc, userId = result.Id, UserName = result.Username, FullName = result.GetFullName() }; return(View("~/Themes/Pavilion/Views/Harag/Profile/MainProfile.cshtml", model)); }