Beispiel #1
0
        public ActionResult PersonalPageWeike(int userId)
        {
            User user = (User)Session["user"];
            List <FollowData> cuFdList         = FollowDB.FindAllFollowings(userId);
            List <FollowData> fdList           = new List <FollowData>();
            List <User>       commonFollowList = new List <User>();

            if (user == null)
            {
                ViewBag.isCurrentUser = false;
                ViewBag.hasFollow     = false;
            }
            else
            {
                ViewBag.followNoticeNum  = NoticeDB.FindUnReadNoticeByUserIdNType(user.id, "follow").Count + NoticeDB.FindUnReadNoticeByUserIdNType(user.id, "unfollow").Count;
                ViewBag.likeNoticeNum    = NoticeDB.FindUnReadNoticeByUserIdNType(user.id, "like").Count + NoticeDB.FindUnReadNoticeByUserIdNType(user.id, "dislike").Count;
                ViewBag.commentNoticeNum = NoticeDB.FindUnReadNoticeByUserIdNType(user.id, "comment").Count;
                ViewBag.replyNoticeNum   = NoticeDB.FindUnReadNoticeByUserIdNType(user.id, "reply").Count;
                if (userId == user.id)
                {
                    ViewBag.isCurrentUser = true;
                    ViewBag.hasFollow     = false;
                }
                else
                {
                    fdList                = FollowDB.FindAllFollowings(user.id);
                    ViewBag.hasFollow     = false;
                    ViewBag.isCurrentUser = false;
                    foreach (FollowData fd in fdList)
                    {
                        if (fd.follow.following_id == userId)
                        {
                            ViewBag.hasFollow = true;
                            break;
                        }
                    }
                }

                foreach (FollowData fd in fdList)
                {
                    foreach (FollowData cufd in cuFdList)
                    {
                        if (fd.follow.following_id == cufd.follow.following_id)
                        {
                            commonFollowList.Add(UserDB.FindById(cufd.follow.following_id));
                        }
                    }
                }
            }
            ViewBag.commonFollowList = commonFollowList;

            ViewBag.popularWeikeList = WeikeDB.FindByUserId(userId, 3);

            User infoUser = UserDB.FindById(userId);
            Dictionary <string, string> personalInfo = new Dictionary <string, string>()
            {
                { "id", userId + "" },
                { "name", infoUser.name },
                { "portraitSrc", "../avatars/" + infoUser.avatar },
                { "email", infoUser.email },
                { "des", infoUser.des },
                { "tag", infoUser.tag },
                { "followCount", infoUser.followNum + "" },
                { "likeCount", infoUser.favoriteNum + "" },
                { "weikeCount", infoUser.postNum + "" }
            };

            ViewBag.personalInfo = personalInfo;

            List <WeikeData>             wdList            = WeikeDB.FindByUserId(userId);
            Dictionary <WeikeData, bool> weikeData         = new Dictionary <WeikeData, bool>();
            List <FavoriteData>          FavoriteWeikeList = FavoriteDB.FindFavoriteWeikeByUserId(user.id);
            bool hasFavorited = false;

            foreach (WeikeData weike in wdList)
            {
                hasFavorited = false;
                foreach (FavoriteData fw in FavoriteWeikeList)
                {
                    if (weike.weike.weike_id == fw.weike.weike_id)
                    {
                        hasFavorited = true;
                    }
                }
                weikeData.Add(weike, hasFavorited);
            }
            ViewBag.weikeData  = weikeData;
            ViewBag.active     = "PersonalPage/PersonalPageWeike?userId=" + userId;
            ViewBag.fromAction = "PersonalPageWeike";

            return(View());
        }
Beispiel #2
0
        public ActionResult PersonalPageFollows(int userId)
        {
            User user = (User)Session["user"];
            List <FollowData>             cuFdList         = FollowDB.FindAllFollowings(userId);
            List <FollowData>             fdList           = new List <FollowData>();
            List <User>                   commonFollowList = new List <User>();
            Dictionary <FollowData, bool> followList       = new Dictionary <FollowData, bool>();

            if (user == null)
            {
                ViewBag.isCurrentUser = false;
                ViewBag.hasFollow     = false;
            }
            else if (userId == user.id)
            {
                ViewBag.isCurrentUser = true;
                ViewBag.hasFollow     = false;

                foreach (FollowData cufd in cuFdList)
                {
                    followList.Add(cufd, true);
                }
            }
            else
            {
                fdList            = FollowDB.FindAllFollowings(user.id);
                ViewBag.hasFollow = false;
                foreach (FollowData fd in fdList)
                {
                    if (fd.follow.following_id == userId)
                    {
                        ViewBag.hasFollow = true;
                        break;
                    }
                }
                ViewBag.isCurrentUser = false;

                bool hasFollow = false;
                foreach (FollowData cufd in cuFdList)
                {
                    hasFollow = false;
                    foreach (FollowData fd in fdList)
                    {
                        if (fd.follow.following_id == cufd.follow.following_id)
                        {
                            hasFollow = true;
                            commonFollowList.Add(UserDB.FindById(cufd.follow.following_id));
                        }
                    }
                    followList.Add(cufd, hasFollow);
                }
            }
            ViewBag.commonFollowList = commonFollowList;
            ViewBag.followList       = followList;
            ViewBag.popularWeikeList = WeikeDB.FindByUserId(userId, 3);


            User infoUser = UserDB.FindById(userId);
            Dictionary <string, string> personalInfo = new Dictionary <string, string>()
            {
                { "id", userId + "" },
                { "name", infoUser.name },
                { "portraitSrc", "../avatars/" + infoUser.avatar },
                { "email", infoUser.email },
                { "des", infoUser.des },
                { "tag", infoUser.tag },
                { "followCount", infoUser.followNum + "" },
                { "likeCount", infoUser.favoriteNum + "" },
                { "weikeCount", infoUser.postNum + "" }
            };

            ViewBag.personalInfo = personalInfo;

            ViewBag.active     = "PersonalPage/PersonalPageFollows?userId=" + userId;
            ViewBag.fromAction = "PersonalPageFollows";
            return(View());
        }
Beispiel #3
0
        public ActionResult PersonalPageLikes(int userId)
        {
            User user = (User)Session["user"];
            List <FollowData> cuFdList         = FollowDB.FindAllFollowings(userId);
            List <FollowData> fdList           = new List <FollowData>();
            List <User>       commonFollowList = new List <User>();

            if (user == null)
            {
                ViewBag.isCurrentUser = false;
                ViewBag.hasFollow     = false;
            }
            else if (userId == user.id)
            {
                ViewBag.isCurrentUser = true;
                ViewBag.hasFollow     = false;
            }
            else
            {
                fdList            = FollowDB.FindAllFollowings(user.id);
                ViewBag.hasFollow = false;
                foreach (FollowData fd in fdList)
                {
                    if (fd.follow.following_id == userId)
                    {
                        ViewBag.hasFollow = true;
                        break;
                    }
                }
                ViewBag.isCurrentUser = false;

                foreach (FollowData fd in fdList)
                {
                    foreach (FollowData cufd in cuFdList)
                    {
                        if (fd.follow.following_id == cufd.follow.following_id)
                        {
                            commonFollowList.Add(UserDB.FindById(cufd.follow.following_id));
                        }
                    }
                }
            }
            ViewBag.commonFollowList = commonFollowList;
            ViewBag.popularWeikeList = WeikeDB.FindByUserId(userId, 3);

            User infoUser = UserDB.FindById(userId);
            Dictionary <string, string> personalInfo = new Dictionary <string, string>()
            {
                { "id", userId + "" },
                { "name", infoUser.name },
                { "portraitSrc", "../avatars/" + infoUser.avatar },
                { "email", infoUser.email },
                { "des", infoUser.des },
                { "tag", infoUser.tag },
                { "followCount", infoUser.followNum + "" },
                { "likeCount", infoUser.favoriteNum + "" },
                { "weikeCount", infoUser.postNum + "" }
            };

            ViewBag.personalInfo = personalInfo;

            List <FavoriteData> favoriteList      = FavoriteDB.FindFavoriteWeikeByUserId(userId);
            List <WeikeData>    favoriteWeikeList = new List <WeikeData>();

            foreach (FavoriteData fdata in favoriteList)
            {
                favoriteWeikeList.Add(WeikeDB.FindByWeikeId(fdata.weike.weike_id));
            }
            ViewBag.weikeData = favoriteList;


            Dictionary <string, string> follow3 = new Dictionary <string, string>()
            {
                { "id", "100" },
                { "name", "用户名" },
                { "imgSrc", "../resource/img/portrait.jpg" },
                { "email", "*********@qq.com" },
                { "hasFollow", "ture" },
                { "isCurrentUser", "false" }
            };

            ViewBag.active     = "PersonalPage/PersonalPageLikes?userId=" + userId;
            ViewBag.fromAction = "PersonalPageLikes";

            return(View());
        }