Exemplo n.º 1
0
        ///<summary>
        /// 获取同城用户列表
        /// </summary>
        /// <returns>
        /// 同城用户集合
        /// </returns>
        public IList <UserStateModel> GetUserProfileModelListByCity(Guid selfUserID, int index, int count)
        {
            IRepository <UserProfile> profileRep = Factory.Factory <IRepository <UserProfile> > .GetConcrete <UserProfile>();

            IRepository <Account> aRep = Factory.Factory <IRepository <Account> > .GetConcrete <Account>();

            UserProfile            selfProfile = profileRep.Find(new Specification <UserProfile>(up => up.UserID == selfUserID));
            IList <UserProfile>    alllist     = profileRep.FindAll(new Specification <UserProfile>(p => p.City == selfProfile.City).Skip(index).Take(count).OrderByDescending(er => er.Id));
            IList <UserStateModel> target      = new List <UserStateModel>();

            foreach (UserProfile u in alllist)
            {
                if (u.UserID == selfUserID)
                {
                    continue;
                }
                UserStateModel m = new UserStateModel();
                Account        a = aRep.Find(new Specification <Account>(ac => ac.Id == u.UserID));
                m.UserID   = a.Id;
                m.UserName = a.UserName;
                m.UserHead = a.UserHead;
                m.UserTiny = a.Tiny;
                target.Add(m);
            }

            return(target);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 判断是否粉丝
        /// </summary>
        /// <param name="uid">其他博主的id</param>
        /// <param name="id">登录博主的id</param>
        /// <returns></returns>
        public bool IsFollowerOrNot(Guid uid, Guid id)
        {
            bool myFlag = false;
            IRepository <UserFollow> userFollowRep = Factory.Factory <IRepository <UserFollow> > .GetConcrete <UserFollow>();

            IList <UserStateModel> targets = new List <UserStateModel>();

            var x = userFollowRep.FindAll(new Specification <UserFollow>(uf => uf.UserID == id));

            foreach (UserFollow uf in x)
            {
                UserStateModel tmp = new UserStateModel()
                {
                    UserID = uf.Followee, UserName = uf.FolloweeName, UserTiny = uf.FolloweeHead
                };
                targets.Add(tmp);
            }



            foreach (UserStateModel model in targets)
            {
                if (model.UserID == uid)
                {
                    myFlag = true;
                }
            }
            return(myFlag);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查找推荐机构
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public IList <UserStateModel> GetRecommendUser(string username)
        {
            IRepository <UserProperty> uRep = Factory.Factory <IRepository <UserProperty> > .GetConcrete <UserProperty>();

            IRepository <Account> aRep = Factory.Factory <IRepository <Account> > .GetConcrete <Account>();

            IList <UserProperty>   u   = uRep.FindAll(new Specification <UserProperty>(p => p.BlogName == username & p.Type == "company"));
            IList <UserStateModel> usm = new List <UserStateModel>();

            //先通过博客名查找
            if (u.Count != 0)
            {
                foreach (UserProperty upy in u)
                {
                    Account        a     = null;
                    UserStateModel model = new UserStateModel();
                    a              = aRep.Find(new Specification <Account>(p => p.Id == upy.UserID));
                    model.UserID   = upy.UserID;
                    model.UserName = upy.BlogName;
                    model.UserTiny = a.Tiny;
                    model.UserHead = a.UserHead;
                    model.Display  = upy.Display;
                    usm.Add(model);
                }
            }
            else if (u.Count == 0)
            {
                //再通过用户名查找
                IList <Account> alist = aRep.FindAll(new Specification <Account>(ac => ac.UserName == username));
                if (alist.Count != 0)
                {
                    foreach (Account acc in alist)
                    {
                        UserStateModel model = new UserStateModel();
                        UserProperty   up    = uRep.Find(new Specification <UserProperty>(p => p.UserID == acc.Id & p.Type == "company"));
                        if (up != null)
                        {
                            model.UserID   = acc.Id;
                            model.UserName = acc.UserName;
                            model.UserTiny = acc.Tiny;
                            model.UserHead = acc.UserHead;
                            model.Display  = up.Display;
                            usm.Add(model);
                        }
                    }
                }
            }
            return(usm);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 关注某人
        /// </summary>
        /// <param name="uid">用户编号</param>
        /// <param name="follow">关注对象编号</param>
        public void FollowSomeBody(AddFolloweeModel model)
        {
            IRepository <UserFollow> followRep = Factory.Factory <IRepository <UserFollow> > .GetConcrete <UserFollow>();

            IRepository <UserProperty> userProRep = Factory.Factory <IRepository <UserProperty> > .GetConcrete <UserProperty>();

            IRepository <ShortMessage> smRep = Factory.Factory <IRepository <ShortMessage> > .GetConcrete <ShortMessage>();

            UserProperty userProperty   = userProRep.Find(new Specification <UserProperty>(uf => uf.UserID == model.UserID));
            UserProperty followProperty = userProRep.Find(new Specification <UserProperty>(uf => uf.UserID == model.FolloweeID));



            //新建用户关注实例
            UserFollow newUserFollow = new UserFollow(model.UserID, model.UserName, model.UserHead, model.FolloweeID, model.FolloweeName, model.FolloweeHead);

            //加入仓储
            followRep.Add(newUserFollow);
            //持久化
            followRep.PersistAll();

            //增加关注数
            userProperty.AddFolloweesCount();
            //增加粉丝数
            followProperty.AddFollowersCount();
            userProRep.Update(userProperty);
            userProRep.Update(followProperty);
            userProRep.PersistAll();

            //发送消息
            string       subject = model.UserName + "关注了你";
            string       content = "<a href='" + Utils.UrlFactory.CreateUrl(FBS.Utils.UrlFactory.PageName.UserHome, model.UserID.ToString()) + "' target='_blank'>" + model.UserName + "</a>关注了你 <span>" + DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "</span>";
            ShortMessage newMsg  = new ShortMessage(model.UserID, model.UserName, model.UserHead, model.FolloweeID, model.FolloweeName, model.FolloweeHead, subject, content);

            //UserEntryService k = new UserEntryService();
            UserStateModel me        = this.GetUserInfo(model.UserID);
            UserStateModel follow    = this.GetUserInfo(model.FolloweeID);
            NewFeedModel   feedModel = new NewFeedModel()
            {
                Content = "", Sharer = me, SourceUser = follow, Subject = "", Type = FeedType.Support
            };
            BlogService my = new BlogService();

            my.CreateFeed(feedModel);

            smRep.Add(newMsg);
            smRep.PersistAll();
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取某人的关注
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public IList <UserStateModel> FetchFolloweesByuserID(Guid uid)
        {
            IRepository <UserFollow> userFollowRep = Factory.Factory <IRepository <UserFollow> > .GetConcrete <UserFollow>();

            IList <UserStateModel> targets = new List <UserStateModel>();

            var x = userFollowRep.FindAll(new Specification <UserFollow>(uf => uf.UserID == uid));

            foreach (UserFollow uf in x)
            {
                UserStateModel tmp = new UserStateModel()
                {
                    UserID = uf.Followee, UserName = uf.FolloweeName, UserTiny = uf.FolloweeHead
                };
                targets.Add(tmp);
            }

            return(targets);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获取某人的粉丝
        /// </summary>
        /// <param name="uid">用户编号</param>
        /// <param name="startIndex">起始索引</param>
        /// <param name="count">数目</param>
        public IList <UserStateModel> FetchFollowersByUserID(Guid uid, int startIndex, int count)
        {
            IRepository <UserFollow> userFollowRep = Factory.Factory <IRepository <UserFollow> > .GetConcrete <UserFollow>();

            IList <UserStateModel> targets = new List <UserStateModel>();

            var x = userFollowRep.FindAll(new Specification <UserFollow>(uf => uf.Followee == uid).Skip(startIndex).Take(count).OrderByDescending(uf => uf.Id));

            foreach (UserFollow uf in x)
            {
                UserStateModel tmp = new UserStateModel()
                {
                    UserID = uf.UserID, UserName = uf.UserName, UserTiny = uf.UserHead
                };
                targets.Add(tmp);
            }

            return(targets);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取用户状态模型
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public UserStateModel GetUserInfo(Guid id)
        {
            //IAccountRepository accRep = Factory.Factory<IAccountRepository>.GetConcrete();
            IRepository <Account> accRep = Factory.Factory <IRepository <Account> > .GetConcrete <Account>();

            Account        user = null;
            UserStateModel usm  = null;

            user = accRep.GetByKey(id);
            if (user == null)
            {
                throw new NoAccountException("用户不存在");
            }
            usm = new UserStateModel()
            {
                UserID = user.Id, UserName = user.UserName, UserTiny = user.Tiny, UserHead = user.UserHead
            };

            return(usm);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取用户好友列表
        /// </summary>
        /// <param name="uid">用户编号</param>
        /// <returns>好友列表</returns>
        public IList <UserStateModel> FetchFriendsStateModelByUserID(Guid uid, int startIndex, int count)
        {
            IRepository <UserFriend> accountRep = Factory.Factory <IRepository <UserFriend> > .GetConcrete <UserFriend>();

            IList <UserFriend> friendList = accountRep.FindAll(new Specification <UserFriend>(uf => uf.Id == uid).Skip(startIndex).Take(count).OrderByDescending(uf => uf.CreatedOn));

            IList <UserStateModel> targets = new List <UserStateModel>();

            foreach (UserFriend uf in friendList)
            {
                UserStateModel tmp = new UserStateModel();
                tmp.UserHead = uf.FriendHead;
                tmp.UserID   = uf.FriendId;
                //tmp.UserTiny=uf.
                //tmp.
                tmp.UserName = uf.FriendName;
                targets.Add(tmp);
            }

            return(targets);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 取消对某人的关注
        /// </summary>
        /// <param name="uid">用户编号</param>
        /// <param name="follow">关注对象编号</param>

        public void CancelFollow(Guid uid, Guid follow)
        {
            IRepository <UserFollow> followRep = Factory.Factory <IRepository <UserFollow> > .GetConcrete <UserFollow>();

            IRepository <UserProperty> userProRep = Factory.Factory <IRepository <UserProperty> > .GetConcrete <UserProperty>();


            UserProperty userProperty   = userProRep.Find(new Specification <UserProperty>(uf => uf.UserID == uid));
            UserProperty followProperty = userProRep.Find(new Specification <UserProperty>(uf => uf.UserID == follow));

            UserFollow userFollow = followRep.Find(new Specification <UserFollow>(uf => uf.UserID == uid && uf.Followee == follow));

            //取消关注
            followRep.Remove(userFollow);
            //持久化
            followRep.PersistAll();

            //减少关注数
            userProperty.ReduceFolloweesCount();
            //减少粉丝数
            followProperty.ReduceFollowersCount();
            userProRep.Update(userProperty);
            userProRep.Update(followProperty);
            userProRep.PersistAll();

            //短消息


            UserInfoService k         = new UserInfoService();
            UserStateModel  me        = k.GetUserInfo(uid);
            UserStateModel  follower  = k.GetUserInfo(follow);
            NewFeedModel    feedModel = new NewFeedModel()
            {
                Content = "", Sharer = me, SourceUser = follower, Subject = "", Type = FeedType.CancelSupport
            };
            BlogService my = new BlogService();

            my.CreateFeed(feedModel);
        }
Exemplo n.º 10
0
 public static void CreateUser(UserStateModel stateModel)
 {
     throw new NotImplementedException();
 }