public ActionResult Index(int?page, string type, string q, int groupId = 0) { YSWL.MALL.ViewModel.SNS.GroupInfo groupInfo = new MALL.ViewModel.SNS.GroupInfo(); groupId = groupId > 0 ? groupId : GroupId; groupInfo.Group = bllGroups.GetModel(groupId); ViewBag.GroupId = groupId; ViewBag.GetType = type; if (null != groupInfo.Group) { ViewBag.IsCreator = (CurrentUser != null && groupInfo.Group.CreatedUserId == CurrentUser.UserID); //小组帖子数 ViewBag.toalcount = groupInfo.Group.TopicCount; } //重置页面索引 page = page.HasValue && page.Value > 1 ? page.Value : 1; //页大小 int pagesize = 10; //计算分页起始索引 int startIndex = page.Value > 1 ? (page.Value - 1) * pagesize + 1 : 1; //计算分页结束索引 int endIndex = page.Value * pagesize; //总记录数 int toalcount = 0; switch (type) { case "Search": //小组帖子搜索 //推荐帖子 q = Common.InjectionFilter.Filter(q); toalcount = bllTopic.GetCountByKeyWord(q, groupId); ViewBag.q = q; ViewBag.toalcount = toalcount; groupInfo.TopicList = new PagedList <YSWL.MALL.Model.SNS.GroupTopics>( bllTopic.SearchTopicByKeyWord(startIndex, endIndex, q, groupId, "") , page ?? 1, pagesize, toalcount); if (Request.IsAjaxRequest()) { return(PartialView(CurrentThemeViewPath + "/Group/TopicList.cshtml", groupInfo.TopicList)); } break; case "User": //小组管理员 groupInfo.AdminUserList = bllGroupUser.GetAdminUserList(groupId); if (groupInfo.AdminUserList.Count > 0 && groupInfo.AdminUserList[0].Role == 2) { BLL.Members.UsersExp bllUser = new BLL.Members.UsersExp(); groupInfo.AdminUserList[0].User = bllUser.GetUsersExpModelByCache(groupInfo.AdminUserList[0].UserID); } //小组成员总数 非管理员用户 toalcount = bllGroupUser.GetRecordCount("GroupId=" + groupId + " AND Role = 0"); //小组成员分页加载 非管理员用户 groupInfo.UserList = new PagedList <Model.SNS.GroupUsers>( bllGroupUser.GetUserList(groupId, startIndex, endIndex) , page ?? 1, pagesize, toalcount); if (Request.IsAjaxRequest()) { return(PartialView(CurrentThemeViewPath + "/Group/UserList.cshtml", groupInfo)); } break; case "Recommand": //推荐帖子 toalcount = bllTopic.GetRecommandCount(groupId); groupInfo.TopicList = new PagedList <YSWL.MALL.Model.SNS.GroupTopics>( bllTopic.GetTopicListPageByGroup(groupId, startIndex, endIndex, true) , page ?? 1, pagesize, toalcount); if (Request.IsAjaxRequest()) { return(PartialView(CurrentThemeViewPath + "/Group/TopicList.cshtml", groupInfo.TopicList)); } break; default: //帖子 toalcount = bllTopic.GetRecordCount(" Status=1 and GroupID=" + groupId); groupInfo.TopicList = new PagedList <YSWL.MALL.Model.SNS.GroupTopics>( bllTopic.GetTopicListPageByGroup(groupId, startIndex, endIndex, false) , page ?? 1, pagesize, toalcount); ViewBag.page = (toalcount + pagesize - 1) / pagesize; if (Request.IsAjaxRequest()) { return(PartialView("_ReplyList", groupInfo)); } break; } groupInfo.NewTopicList = bllTopic.GetNewTopListByGroup(groupId, 10); groupInfo.NewUserList = bllGroupUser.GetNewUserListByGroup(groupId, 9); ViewBag.joined = (currentUser != null && bllGroupUser.Exists(groupId, currentUser.UserID)) ? "ok" : "error"; #region SEO 优化设置 IPageSetting pageSetting = PageSetting.GetPageSetting("GroupList", ApplicationKeyType.SNS); pageSetting.Replace( new[] { PageSetting.RKEY_CNAME, null != groupInfo.Group?groupInfo.Group.GroupName:"" }, //小组名称 new[] { PageSetting.RKEY_CTAG, null != groupInfo.Group?groupInfo.Group.Tags:"" }, //小组标签 new[] { PageSetting.RKEY_CDES, null != groupInfo.Group?groupInfo.Group.GroupDescription:"" }); //小组描述 ViewBag.Title = pageSetting.Title; ViewBag.Keywords = pageSetting.Keywords; ViewBag.Description = pageSetting.Description; #endregion return(View(groupInfo)); }
public PartialViewResult TopicReply(int Id, int?page, string viewName = "TopicReply", string ajaxvName = "TopicReplyList") { //if (!bllTopic.Exists(Id) || !bllTopic.UpdatePVCount(Id)) //{ // return RedirectToAction("Index", "Group"); // ViewBag.support = "nosupport"; if (null != CurrentUser) { HttpCookie cookie = Request.Cookies["topicFav_" + Id + CurrentUser.UserID]; if (null != cookie) //取消赞 { ViewBag.support = "support"; } } YSWL.MALL.ViewModel.SNS.TopicReply Model = new TopicReply(); Model.Topic = bllTopic.GetModel(Id); ViewBag.Activity = "invalid"; if (null != Model.Topic && null != CurrentUser) { if (Model.Topic.CreatedUserID == CurrentUser.UserID) //自己的帖子 { ViewBag.Activity = "active"; } } //重置页面索引 page = page.HasValue && page.Value > 1 ? page.Value : 1; ViewBag.page = page + 1; //页大小 int pagesize = 10; //计算分页起始索引 int startIndex = page.Value > 1 ? (page.Value - 1) * pagesize + 1 : 1; //计算分页结束索引 int endIndex = page.Value * pagesize; //总记录数 int toalcount = bllReply.GetRecordCount(" Status=1 and TopicID =" + Id); List <YSWL.MALL.Model.SNS.GroupTopicReply> list = bllReply.GetTopicReplyByTopic(Id, startIndex, endIndex); if (list != null && list.Count > 0) { Model.TopicsReply = new PagedList <YSWL.MALL.Model.SNS.GroupTopicReply>(list, page ?? 1, pagesize, toalcount); } if (Request.IsAjaxRequest()) { return(PartialView(ajaxvName, Model)); } Model.UserJoinGroups = bllGroups.GetUserJoinGroup(Model.Topic != null ? Model.Topic.CreatedUserID : 0, 9); Model.HotTopic = bllTopic.GetHotListByGroup(Model.Topic.GroupID, 9); Model.Group = bllGroups.GetModel(Model.Topic.GroupID); Model.UserPostTopics = bllTopic.GetTopicByUserId(Model.Topic.CreatedUserID, 9); #region SEO 优化设置 IPageSetting pageSetting = PageSetting.GetPageSetting("GroupDetail", ApplicationKeyType.SNS); pageSetting.Replace( new[] { PageSetting.RKEY_CNAME, Model.Group.GroupName }, //小组名称 new[] { PageSetting.RKEY_CTNAME, Model.Topic.Title }, //帖子标题 new[] { PageSetting.RKEY_CTAG, Model.Topic.Tags }, //帖子标签 new[] { PageSetting.RKEY_CDES, Model.Topic.Description }); //帖子内容 ViewBag.Title = pageSetting.Title; ViewBag.Keywords = pageSetting.Keywords; ViewBag.Description = pageSetting.Description; #endregion return(PartialView(viewName, Model)); }