コード例 #1
0
        public ActionResult AjaxJoinGroup(FormCollection fm)
        {
            YSWL.MALL.Model.SNS.GroupUsers model = new Model.SNS.GroupUsers();
            YSWL.MALL.BLL.SNS.GroupUsers   bll   = new YSWL.MALL.BLL.SNS.GroupUsers();
            int GroupId = Common.Globals.SafeInt(fm["GroupId"], 0);

            if (null == CurrentUser)
            {
                return(Content("notLogin"));
            }
            if (bll.Exists(GroupId, currentUser.UserID))
            {
                return(Content("joined"));
            }
            model.GroupID  = GroupId;
            model.JoinTime = DateTime.Now;
            model.NickName = currentUser.NickName;
            model.UserID   = currentUser.UserID;
            model.Status   = 1;
            if (bll.AddEx(model))
            {
                return(Content("Yes"));
            }
            return(Content("No"));
        }
コード例 #2
0
        public ActionResult AJaxCheckUserIsJoinGroup(FormCollection fm)
        {
            YSWL.MALL.Model.SNS.GroupUsers model = new Model.SNS.GroupUsers();
            YSWL.MALL.BLL.SNS.GroupUsers   bll   = new YSWL.MALL.BLL.SNS.GroupUsers();
            int GroupId = Common.Globals.SafeInt(fm["GroupId"], 0);

            if (bll.Exists(GroupId, currentUser.UserID))
            {
                return(Content("joined"));
            }
            return(Content("No"));
        }
コード例 #3
0
        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));
        }