Exemple #1
0
        /// <summary>
        /// 主题详细列表Json方式获取
        /// </summary>
        /// <param name="topicId"></param>
        /// <param name="isTag"> 0表示所有楼层都显示 其它Id代表具体那楼层Id。</param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public JsonResult TopicDetailJsonList(int topicId, int floorId, int pageIndex)
        {
            PageResultModel model = new PageResultModel();

            IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL");

            //主题下面所有的一级Ids
            var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == topicId && m.ParentId == null, "PostTime", true).Select(m => m.Id).ToList();

            Expression <Func <T_PostBarTopicDiscuss, bool> > where = m => true;

            if (floorId > 0)
            {
                where = PredicateBuilder.And(where, m => m.TopicId == topicId && m.Id == floorId);
            }
            else
            {
                where = PredicateBuilder.And(where, m => m.TopicId == topicId && m.ParentId == null);
            }

            // 获取我的帖子回复列表
            var list = topicDiscussBLL.GetPageList(where, "PostTime", true, pageIndex, ConstantParam.PAGE_SIZE).Select(m => new
            {
                Id              = m.Id,
                UserId          = m.PostUserId,
                PostDate        = TimeFormat(m.PostTime),
                UserImage       = m.PostUser.HeadPath,
                UserName        = m.PostUser.UserName,
                Content         = m.Content == null ? "" : m.Content,
                PicList         = m.ImgPath,
                RepliedUserName = m.ReplyUser.UserName,
                Level2Count     = m.PostBarTopicDiscusses.Count(),
                PropertyPlaceId = m.PostBarTopic.PropertyPlaceId,
                FloorNo         = level1Ids.FindIndex(l => l == m.Id) + 1,

                Level2DiscussList = m.PostBarTopicDiscusses.Select(o =>
                                                                   new
                {
                    Level2Id              = o.Id,
                    Level2ParentId        = o.ParentId,
                    Level2UserId          = o.PostUserId,
                    Level2UserName        = o.PostUser.UserName,
                    Level2Content         = o.Content,
                    Level2PostDate        = TimeFormat(o.PostTime),
                    Level2RepliedUserName = o.ReplyUser.UserName,
                    Level2PicList         = o.ImgPath
                }).OrderByDescending(o => o.Level2PostDate).Take(2).ToList(),
                Level2DiscussListCount = m.PostBarTopicDiscusses.Count()
            }).ToList();

            model.Result = list;
            model.Total  = topicDiscussBLL.Count(m => m.TopicId == topicId && m.ParentId == null);

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        /// <summary>
        /// 楼层详细列表
        /// </summary>
        /// <param name="floorId">一级回复的主键Id</param>
        /// <param name="replyId">准备要回复对方的Id</param>
        /// <returns></returns>
        public ActionResult FloorDetailList(int floorId, int replyId)
        {
            int CurrentUserId = GetCurrentUser().Id;

            WeixinApiInit();

            //获取当前楼层(也就是一级回复的)信息
            IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL");

            var topicDiscuss = topicDiscussBLL.GetEntity(m => m.Id == floorId);
            //主题下面所有的一级Ids
            var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == topicDiscuss.TopicId && m.ParentId == null).OrderBy(m => m.PostTime).Select(m => m.Id).ToList();
            //当前是第几楼
            int FloorNo = level1Ids.FindIndex(m => m == floorId) + 1;

            ViewBag.FloorNo = string.Format("{0}楼", FloorNo);

            IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            var replidUserName = "";

            var replyUser = userBll.GetEntity(m => m.Id == replyId);

            replidUserName = string.Format("回复{0}:", replyUser.UserName);

            var model = new TopicFloorDetailModel()
            {
                FloorId            = topicDiscuss.Id,
                FloorNo            = string.Format("第{0}楼", FloorNo),
                PostUserId         = topicDiscuss.PostUserId,
                PostUserName       = topicDiscuss.PostUser.UserName,
                PostUserHeadPath   = topicDiscuss.PostUser.HeadPath,
                ImgPath            = topicDiscuss.ImgPath,
                ImgThumbnail       = topicDiscuss.ImgThumbnail,
                PostDate           = string.Format("第{0}楼 {1}", FloorNo, TimeFormat(topicDiscuss.PostTime)),
                Content            = topicDiscuss.Content,
                PropertyPlaceId    = topicDiscuss.PostBarTopic.PropertyPlaceId,
                TopicId            = topicDiscuss.PostBarTopic.Id,
                LevelTwoReplyCount = topicDiscussBLL.Count(m => m.ParentId == topicDiscuss.Id && m.TopicId == topicDiscuss.TopicId),
                ReplyId            = replyId,
                ReplidUserName     = replidUserName,
                CurrentUserId      = CurrentUserId,
                CanDelete          = topicDiscuss.PostUserId == CurrentUserId
            };

            return(View(model));
        }
        public ApiResultModel GetMyReplyOneTwoLevelsList([FromUri] ReplyOneTwoLevelModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    var collectedTopicIds = owner.UserPostBarTopics.Select(o => o.PostBarTopicId).ToList();

                    IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL");

                    //获取一级
                    var topicDiscuss = topicDiscussBLL.GetEntity(m => m.Id == model.Id);
                    int topicId      = topicDiscuss.TopicId;
                    int level1Id     = model.Id;

                    var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == topicId && m.ParentId == null).OrderBy(m => m.PostTime).Select(m => m.Id).ToList();

                    if (topicDiscuss.ParentId.HasValue)
                    {
                        level1Id     = topicDiscussBLL.GetEntity(m => m.TopicId == topicId && m.ParentId == null && m.Id == topicDiscuss.ParentId.Value).Id;
                        topicDiscuss = topicDiscussBLL.GetEntity(m => m.Id == level1Id);
                    }

                    int FloorNo = level1Ids.FindIndex(m => m == level1Id) + 1;

                    //根据一级获取二级
                    var list = new
                    {
                        Id               = topicDiscuss.Id,
                        PostUserId       = topicDiscuss.PostUserId,
                        PostDate         = topicDiscuss.PostTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        UserImage        = topicDiscuss.PostUser.HeadPath,
                        UserName         = topicDiscuss.PostUser.UserName,
                        Content          = topicDiscuss.Content,
                        PicList          = topicDiscuss.ImgPath,
                        TopicId          = topicDiscuss.PostBarTopic.Id,
                        Title            = topicDiscuss.PostBarTopic.Title,
                        TopicContent     = topicDiscuss.PostBarTopic.Content,
                        TopicUserId      = topicDiscuss.PostBarTopic.PostUserId,
                        TopicUserName    = topicDiscuss.PostBarTopic.PostUser.UserName,
                        TopicUserImage   = topicDiscuss.PostBarTopic.PostUser.HeadPath,
                        TopicPicList     = topicDiscuss.PostBarTopic.ImgPath,
                        TopicPostDate    = topicDiscuss.PostBarTopic.PostDate.ToString("yyyy-MM-dd HH:mm:ss"),
                        Level2Count      = topicDiscuss.PostBarTopicDiscusses.Count,
                        FloorNo          = FloorNo,
                        TopicIsTop       = topicDiscuss.PostBarTopic.IsTop,
                        TopicIsCollected = collectedTopicIds.Contains(topicDiscuss.TopicId) ? 1 : 0,
                        PropertyPlaceId  = topicDiscuss.PostBarTopic.PropertyPlaceId,
                        Level2List       = topicDiscuss.PostBarTopicDiscusses.Select(o =>
                                                                                     new
                        {
                            Level2ParentId        = o.ParentId,
                            Level2PostUserId      = o.PostUserId,
                            Level2UserName        = o.PostUser.UserName,
                            Level2Content         = o.Content,
                            Level2PostDate        = o.PostTime.ToString("yyyy-MM-dd HH:mm:ss"),
                            Level2RepliedUserName = o.ReplyUser.UserName,
                            Level2PicList         = o.ImgPath
                        }).OrderByDescending(o => o.Level2PostDate).Take(2).ToList()
                    };

                    resultModel.result = list;
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
        public ApiPageResultModel GetMyTopicReplyList([FromUri] TopicDetailsModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL");

                    var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == model.TopicId && m.ParentId == null).OrderBy(m => m.PostTime).Select(m => m.Id).ToList();

                    // 获取我的帖子回复列表
                    var list = topicDiscussBLL.GetPageList(m => m.TopicId == model.TopicId && m.ParentId == null, "PostTime", true, model.PageIndex, ConstantParam.PAGE_SIZE).Select(m => new
                    {
                        Id              = m.Id,
                        UserId          = m.PostUserId,
                        PostDate        = m.PostTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        UserImage       = m.PostUser.HeadPath,
                        UserName        = m.PostUser.UserName,
                        Content         = m.Content,
                        PicList         = m.ImgPath,
                        RepliedUserName = m.ReplyUser.UserName,
                        Level2Count     = m.PostBarTopicDiscusses.Count(),
                        PropertyPlaceId = m.PostBarTopic.PropertyPlaceId,
                        FloorNo         = level1Ids.FindIndex(l => l == m.Id) + 1,

                        Level2DiscussList = m.PostBarTopicDiscusses.Select(o =>
                                                                           new
                        {
                            Level2Id              = o.Id,
                            Level2ParentId        = o.ParentId,
                            Level2UserName        = o.PostUser.UserName,
                            Level2Content         = o.Content,
                            Level2PostDate        = o.PostTime.ToString("yyyy-MM-dd HH:mm:ss"),
                            Level2RepliedUserName = o.ReplyUser.UserName,
                            Level2PicList         = o.ImgPath
                        }).OrderBy(o => o.Level2PostDate).Take(2).ToList()
                    }).ToList();

                    resultModel.result = list;
                    resultModel.Total  = topicDiscussBLL.Count(m => m.TopicId == model.TopicId && m.ParentId == null);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }