Exemplo n.º 1
0
        public string SetFollow(int quertid, string isf, int UserType)
        {
            int        uid   = user.Uid;
            ViewFollow model = new ViewFollow();

            model.Uid      = uid;
            model.QuiltUid = quertid;
            model.iType    = UserType;
            string restring = null;
            int    reid     = 0;

            if (uid != quertid)
            {
                if (isf == "+关注")
                {
                    using (FollowServiceClient clent = new FollowServiceClient())
                    {
                        model = clent.GetFollowById(uid, quertid);
                        if (model != null)
                        {
                            //update
                            model.FollowDate = DateTime.Now;
                            model.isfollow   = true;

                            clent.Update(model);
                        }
                        else
                        {
                            //insert
                            model               = new ViewFollow();
                            model.Uid           = uid;
                            model.QuiltUid      = quertid;
                            model.FollowDate    = DateTime.Now;
                            model.isfollow      = true;
                            model.iType         = UserType;
                            model.QuiltCenterID = user.UserType;
                            model.loginType     = 0;
                            clent.Add(model);
                        }
                        restring = "1";
                    }
                }
                else if (isf == "已关注")
                {
                    using (FollowServiceClient clent = new FollowServiceClient())
                    {
                        model = clent.GetFollowById(uid, quertid);

                        model.isfollow   = false;
                        model.FollowDate = DateTime.Now;
                        reid             = clent.Update(model);

                        restring = "0";
                    }
                }
            }
            else
            {
                restring = "3";//自己不需要关注自己
            }
            return(restring);
        }
Exemplo n.º 2
0
        //被关注
        public ActionResult FollowIndex(int page = 1)
        {
            List <ViewFollow> listWhere0 = followclient.GetFollowQuiltUidList(user.Uid, 0, out count);

            if (count > 0)
            {
                //第一次登录
                foreach (ViewFollow item in listWhere0)
                {
                    item.loginType = 1;
                    followclient.Update(item);
                }
            }
            else
            {
                List <ViewFollow> listWhere1 = followclient.GetFollowQuiltUidList(user.Uid, 1, out count);
                if (count > 0)
                {
                    foreach (ViewFollow item in listWhere1)
                    {
                        item.loginType = 2;
                        followclient.Update(item);
                    }
                }
            }

            List <ViewFollow>      followlist = followclient.GetFollowQuiltUidList(user.Uid, page, 10, out count);
            PagedList <ViewFollow> pagelist   = new PagedList <ViewFollow>(followlist, page, 10, count);

            #region
            List <ViewFollowUserDetail> listFollowGroup = new List <ViewFollowUserDetail>();
            foreach (var item in followlist)
            {
                ViewYogaUser userEntity = clientUser.GetYogaUserById(item.Uid);

                ViewFollowUserDetail model = new ViewFollowUserDetail();
                model.FollowersName = userEntity.NickName;//昵称

                model.flag       = item.iType.Value;
                model.CreateTime = item.FollowDate;
                model.iNew       = item.loginType.Value;
                if (userEntity.UserType == 0)
                {
                    //习练者
                    ViewYogaUserDetail udmodel = udclient.GetYogaUserDetailById(item.Uid);
                    model.spic    = CommonInfo.GetDisplayImg(udmodel.DisplayImg);
                    model.userurl = "/YogaUserDetail/Details/";
                    model.uid     = udmodel.UID;

                    listFollowGroup.Add(model);
                }
                else if (userEntity.UserType == 1)
                {
                    //导师
                    ViewYogisModels mmodel = clientModel.GetYogisModelsById(item.Uid);
                    model.spic = CommonInfo.GetDisplayImg(mmodel.DisplayImg);

                    if (mmodel.YogisLevel == 4)
                    {
                        model.userurl  = "/YogaGuru/Details/";
                        model.nickname = mmodel.RealName;
                    }
                    else
                    {
                        model.userurl = "/YogisModels/Details/";
                    }

                    model.uid = mmodel.UID;

                    listFollowGroup.Add(model);
                }
            }

            ViewBag.listFollowGroup = listFollowGroup;

            #endregion

            return(View("FollowIndex", pagelist));
        }