public ActionResult Index(string id) { var myuserId = User.Identity.GetUserId(); if (string.IsNullOrEmpty(id)) { id = myuserId; } var model = _userServiceAgent.GetUserById(id); model.Posts = _postServiceAgent.GetLatestPostByUser(id)?.ToList() ?? new List <PostViewModel>(); model.Following = _userServiceAgent.FollowingList(id, myuserId).Select(x => x.UserInfo).ToList(); model.Followers = _userServiceAgent.FollowersList(id, myuserId).Select(x => x.UserInfo).ToList(); var user = UserManager.FindById(id); if (user != null) { ViewData["username"] = user.UserName; ViewData["userimage"] = string.IsNullOrEmpty(model?.ImageUrl) ? @"\images\DefaultPhoto.png" : model?.ImageUrl; ViewData["firstname"] = string.IsNullOrEmpty(model?.FirstName) ? "FirstName" : model?.FirstName; } return(View(model)); }
public ActionResult Followers(string id) { var userid = string.IsNullOrEmpty(id) ? User.Identity.GetUserId() : id; var model = _userServiceAgent.FollowersList(userid, User.Identity.GetUserId()); var userModel = _userServiceAgent.GetByUserId(userid); ViewBag.Image = userModel.ImageUrl; ViewBag.Text = userModel.FirstName + " has " + model.Count + " followers."; return(View("Index", model)); }
public ActionResult Index() { var myuserId = User.Identity.GetUserId(); var model = _userServiceAgent.GetUserById(myuserId); model.Posts = _postServiceAgent.GetLatestPostByUser(myuserId)?.ToList() ?? new List <PostViewModel>(); model.Following = _userServiceAgent.FollowingList(myuserId, myuserId).Select(x => x.UserInfo).ToList(); model.Followers = _userServiceAgent.FollowersList(myuserId, myuserId).Select(x => x.UserInfo).ToList(); return(View(model)); }