Ejemplo n.º 1
0
        public ActionResult LoadUserInfo(long userId)
        {
            if (userId == 0)
            {
                return(View());
            }
            var user = UserService.GetUserById(userId);

            if (user == null)
            {
                return(View());
            }
            return(Json(new AjaxResult
            {
                Status = "OK",
                Data = new UserInfo
                {
                    Id = user.Id,
                    Biography = user.Biography,
                    FollowerCount = FollowService.GetFollowerCount(userId),
                    FollowingCount = FollowService.GetFollowingCount(userId),
                    FullName = user.FullName,
                    PostCount = PostService.GetPostCount(userId),
                    ProfilePic = user.ProfilePic,
                    UserName = user.UserName,
                    IsFollowing = FollowService.IsFollowing(Convert.ToInt64(Session["userId"]), userId)
                }
            }));
        }
Ejemplo n.º 2
0
 public ActionResult Index(long?id)
 {
     //IUserService UserService1 = new Service.UserService();
     if (id == null)
     {
         return(View());
     }
     ViewBag.FollowerCount  = FollowService.GetFollowerCount(id.Value);
     ViewBag.FollowingCount = FollowService.GetFollowingCount(id.Value);
     if (Convert.ToInt64(Session["userId"]) != id.Value)
     {
         ViewBag.Following = FollowService.IsFollowing(Convert.ToInt64(Session["userId"]), id.Value);
     }
     ViewBag.PostCount = PostService.GetPostCount(id.Value);
     ViewBag.PostList  = PostService.GetPostPagerList(id.Value, PageSize, 1).Select(
         p => new PostInfo(p));
     return(View(UserService.GetUserById(id.Value)));
 }
Ejemplo n.º 3
0
        public ActionResult LoadFollowing(long userId, int pageIndex = 1)
        {
            long            accountId     = Convert.ToInt64(Session["userId"]);
            List <UserInfo> userList      = new List <UserInfo>();
            var             followingList = FollowService.GetFollowingPagerList(userId, 12, pageIndex);

            foreach (var followingId in followingList)
            {
                var user = UserService.GetUserById(followingId);
                userList.Add(new UserInfo
                {
                    Id          = user.Id,
                    FullName    = user.FullName,
                    UserName    = user.UserName,
                    IsFollowing = FollowService.IsFollowing(accountId, followingId),
                    Biography   = user.Biography.Length > 50 ? user.Biography.Substring(0, 50) + "..." : user.Biography,
                    ProfilePic  = user.ProfilePic
                });
            }
            return(Json(new AjaxResult {
                Status = "OK", Data = userList
            }));
        }