Example #1
0
        public ActionResult Group(int?uid, int?page, int?Type)
        {
            if (!LoadUserInfo(uid == null ? 0 : uid.Value))
            {
                if (MvcApplication.MainAreaRoute == AreaRoute.SNS)
                {
                    //SNS 主域
                    return(Redirect(ViewBag.BasePath + "Account/Login"));
                }
                return(Redirect("/SNS/Account/Login"));
            }
            List <YSWL.MALL.Model.SNS.GroupTopics> ListTopic = new List <Model.SNS.GroupTopics>();

            YSWL.MALL.BLL.SNS.GroupTopics bll = new YSWL.MALL.BLL.SNS.GroupTopics();
            page = page.HasValue && page.Value > 1 ? page.Value : 1;
            Type = Type.HasValue ? Type.Value : 0;
            //页大小
            int pagesize = 10;
            //计算分页起始索引
            int startIndex = page.Value > 1 ? (page.Value - 1) * pagesize + 1 : 1;
            //计算分页结束索引
            int endIndex = page.Value * pagesize;
            //总记录数
            int toalcount = bll.GetCountByType(this.UserID, (YSWL.MALL.Model.SNS.EnumHelper.UserGroupType)Type.Value);

            ListTopic = bll.GetUserRelativeTopicByType(this.UserID, (YSWL.MALL.Model.SNS.EnumHelper.UserGroupType)Type.Value, startIndex, endIndex);
            PagedList <YSWL.MALL.Model.SNS.GroupTopics> PagedTopicList = new PagedList <YSWL.MALL.Model.SNS.GroupTopics>(ListTopic, page ?? 1, pagesize, toalcount);

            ViewBag.IsCurrentUser = this.IsCurrentUser;
            ViewBag.UserId        = this.UserID;
            ViewBag.Type          = (YSWL.MALL.Model.SNS.EnumHelper.UserGroupType)Type.Value;
            ViewBag.NickName      = this.NickName;
            if (Request.IsAjaxRequest())
            {
                return(PartialView(CurrentThemeViewPath + "/UserProfile/TopicList.cshtml", PagedTopicList));
            }

            #region SEO 优化设置
            IPageSetting pageSetting = PageSetting.GetPageSetting("Base", ApplicationKeyType.SNS);
            ViewBag.Keywords    = pageSetting.Keywords;
            ViewBag.Description = pageSetting.Description;
            if (ViewBag.IsCurrentUser == true)
            {
                ViewBag.Title = "我的小组 - " + pageSetting.Title;
            }
            else
            {
                ViewBag.Title = this.NickName + "的小组 - " + pageSetting.Title;
            }
            #endregion
            return(View(CurrentThemeViewPath + "/UserProfile/Group.cshtml", PagedTopicList));
        }
Example #2
0
        public ActionResult AJaxCreateTopic(FormCollection fm)
        {
            int subStringLength = BLL.SysManage.ConfigSystem.GetIntValueByCache("MSNS_GroupTopic_SubLength");

            subStringLength = subStringLength < 1 ? 15 : subStringLength;
            string Title    = Common.StringPlus.SubString(fm["Des"], subStringLength);
            string Des      = fm["Des"] ?? "";
            long   Pid      = Common.Globals.SafeLong(fm["Pid"], 0);
            string ImageUrl = "";

            //商品和图片只能发一个
            if (Pid == 0)
            {
                ImageUrl = fm["ImageUrl"] != null ? fm["ImageUrl"].ToString() : "";
            }
            int GroupId = Common.Globals.SafeInt(fm["GroupId"], 0);

            if (string.IsNullOrEmpty(Title) || string.IsNullOrEmpty(Des))
            {
                return(Content("No"));
            }
            YSWL.MALL.BLL.SNS.GroupTopics   bllTopic   = new YSWL.MALL.BLL.SNS.GroupTopics();
            YSWL.MALL.Model.SNS.GroupTopics modelTopic = new Model.SNS.GroupTopics();
            modelTopic.Title       = Title;
            modelTopic.Description = Des;
            //移动图片
            string savePath       = "/Upload/SNS/Images/Group/" + DateTime.Now.ToString("yyyyMMdd") + "/";
            string saveThumbsPath = "/Upload/SNS/Images/GroupThumbs/" + DateTime.Now.ToString("yyyyMMdd") + "/";

            modelTopic.ImageUrl        = YSWL.MALL.BLL.SNS.Photos.MoveImage(ImageUrl, savePath, saveThumbsPath);
            modelTopic.GroupID         = GroupId;
            modelTopic.GroupName       = "";
            modelTopic.CreatedDate     = DateTime.Now;
            modelTopic.CreatedUserID   = currentUser.UserID;
            modelTopic.CreatedNickName = currentUser.NickName;
            if ((modelTopic.TopicID = bllTopic.AddEx(modelTopic, Pid)) > 0)
            {
                return(Content(modelTopic.TopicID.ToString()));
            }
            //SNS连续发帖冻结帐号
            else if (modelTopic.TopicID == -2)
            {
                //已冻结帐号, 强制用户退出
                System.Web.Security.FormsAuthentication.SignOut();
                Session.Remove(Globals.SESSIONKEY_USER);
                Session.Clear();
                Session.Abandon();
            }
            return(Content("No"));
        }