/// <summary> /// 删除回复 /// </summary> /// <param name="id"></param> /// <param name="level"></param> /// <returns></returns> public JsonResult DelReply(int id, int level) { JsonModel jm = new JsonModel(); try { IPostBarTopicDiscussBLL topicDiscussBll = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); var topicDiscuss = topicDiscussBll.GetEntity(p => p.Id == id); if (topicDiscuss == null) { jm.Msg = "该回复不存在"; } else { if (level == 1) { topicDiscussBll.DeleteLevelOneDiscuss(id); } else { topicDiscussBll.Delete(topicDiscuss); } } } catch { jm.Msg = "删除发生异常"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ApiResultModel DeleteReply(DeleteReplyModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //根据用户ID查找业主 IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); T_User user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); //获取要删除的回复内容 IPostBarTopicDiscussBLL postBarTopicDiscussBll = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); T_PostBarTopicDiscuss reply = postBarTopicDiscussBll.GetEntity(u => u.Id == model.Id); //如果该回复存在 if (reply == null) { resultModel.Msg = "该回复不存在"; } else { if (reply.ParentId == null) { postBarTopicDiscussBll.DeleteLevelOneDiscuss(reply.Id); } else { postBarTopicDiscussBll.Delete(reply); } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public JsonResult DeleteReply(int id) { JsonModel jm = new JsonModel(); //获取要删除的回复内容 IPostBarTopicDiscussBLL postBarTopicDiscussBll = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); T_PostBarTopicDiscuss discuss = postBarTopicDiscussBll.GetEntity(u => u.Id == id); //如果该回复存在 if (discuss == null) { jm.Msg = "该回复不存在"; } else { if (discuss.ParentId == null) { postBarTopicDiscussBll.DeleteLevelOneDiscuss(discuss.Id); } else { postBarTopicDiscussBll.Delete(discuss); } //操作日志 jm.Content = "删除回复" + discuss.Content; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ApiPageResultModel GetMyLevel2RepliesList([FromUri] Level2RepliedListModel 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 level1Disscuss = topicDiscussBLL.GetEntity(m => m.Id == model.Id); // 获取我的二级回复列表 var list = topicDiscussBLL.GetPageList(m => m.ParentId == model.Id && m.TopicId == model.TopicId, "PostTime", true, model.PageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Id = m.Id, PostDate = m.PostTime.ToString("yyyy-MM-dd HH:mm:ss"), UserId = m.PostUserId, UserImage = m.PostUser.HeadPath, UserName = m.PostUser.UserName, Content = m.Content, PicList = m.ImgPath, RepliedUserName = m.ReplyUser.UserName, Level2ParentId = m.ParentId }).ToList(); resultModel.result = list; resultModel.Total = topicDiscussBLL.Count(m => m.ParentId == model.Id && m.TopicId == model.TopicId); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
/// <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); }