public ActionResult GetDataCountByPageType(FormCollection fc) { this.UserID = Common.Globals.SafeInt(fc["UserID"], 0); this.DefaultPostType = GetDefaultPostType(fc["PostType"]); int DataCount = PostsBll.GetCountByPostType(UserID, DefaultPostType, IncludeProduct); return(Content(DataCount.ToString())); }
public Model.SNS.EnumHelper.PostType GetDefaultPostType(string type) { Model.SNS.EnumHelper.PostType PostType = Model.SNS.EnumHelper.PostType.User; if (!string.IsNullOrEmpty(type)) { switch (type) { case "user": PostType = Model.SNS.EnumHelper.PostType.User; break; case "all": PostType = Model.SNS.EnumHelper.PostType.All; break; case "referme": PostType = Model.SNS.EnumHelper.PostType.ReferMe; break; case "eachother": PostType = Model.SNS.EnumHelper.PostType.EachOther; break; case "photo": PostType = Model.SNS.EnumHelper.PostType.Photo; break; case "product": PostType = Model.SNS.EnumHelper.PostType.Product; break; case "video": PostType = Model.SNS.EnumHelper.PostType.Video; break; case "fellow": PostType = Model.SNS.EnumHelper.PostType.Fellow; break; case "blog": PostType = Model.SNS.EnumHelper.PostType.Blog; break; default: PostType = Model.SNS.EnumHelper.PostType.All; break; } } return(PostType); }
public ActionResult Posts(string type, int?uid, string nickname) { #region 如果传过来的是用户的nickname,则对应相应的用户id YSWL.MALL.BLL.Members.Users UserBll = new BLL.Members.Users(); int ID; if (!string.IsNullOrEmpty(nickname) && ((ID = UserBll.GetUserIdByNickName(nickname)) > 0)) { uid = ID; } #endregion //#region 如果是当前的用户 //if (currentUser != null && currentUser.UserID == uid) //{ // return RedirectToAction("Posts", "Profile"); //} //#endregion ViewBag.IsCurrentUser = uid.HasValue ? false : (currentUser != null ? true : false); #region 进行对用户的id重写复制 if (!LoadUserInfo(uid == null ? 0 : uid.Value) || !this.Activity) { if (MvcApplication.MainAreaRoute == AreaRoute.SNS) { //SNS 主域 return(Redirect("/Error/UserError")); } return(Redirect("/SNS/Error/UserError")); } #endregion YSWL.MALL.BLL.SNS.AlbumType AlbumTypeBLL = new YSWL.MALL.BLL.SNS.AlbumType(); YSWL.MALL.ViewModel.SNS.PostsPage postPage = new MALL.ViewModel.SNS.PostsPage(); YSWL.MALL.BLL.Members.PointsDetail pointBll = new BLL.Members.PointsDetail(); postPage.Type = type; #region 初始化查询动态的类型 if (!string.IsNullOrEmpty(type)) { switch (type) { case "user": DefaultPostType = Model.SNS.EnumHelper.PostType.User; break; case "all": DefaultPostType = Model.SNS.EnumHelper.PostType.All; break; case "referme": DefaultPostType = Model.SNS.EnumHelper.PostType.ReferMe; break; case "eachother": DefaultPostType = Model.SNS.EnumHelper.PostType.EachOther; break; case "photo": DefaultPostType = Model.SNS.EnumHelper.PostType.Photo; break; case "product": DefaultPostType = Model.SNS.EnumHelper.PostType.Product; break; case "video": DefaultPostType = Model.SNS.EnumHelper.PostType.Video; break; case "fellow": DefaultPostType = Model.SNS.EnumHelper.PostType.Fellow; break; } } else { if (this.IsCurrentUser == true) { postPage.Type = "fellow"; DefaultPostType = Model.SNS.EnumHelper.PostType.Fellow; } else { postPage.Type = "user"; DefaultPostType = Model.SNS.EnumHelper.PostType.User; } } #endregion postPage.PageSize = _PostPageSize; postPage.DataCount = PostsBll.GetCountByPostType(UserID, DefaultPostType, IncludeProduct); postPage.AlbumTypeList = AlbumTypeBLL.GetModelListByCache(Model.SNS.EnumHelper.Status.Enabled); postPage.UserID = UserID; postPage.Setting = YSWL.MALL.BLL.SNS.ConfigSystem.GetPostSetByCache(); ViewBag.CurrentUserID = UserID; ViewBag.NickName = this.NickName; #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("Posts", postPage)); }
/// <summary> /// 分页获取数据 /// </summary> /// <param name="PageIndex"></param> /// <returns></returns> public ActionResult AjaxGetPostByIndex(FormCollection Fm) { string type = Fm["type"]; int UserId = Common.Globals.SafeInt(Fm["UserID"], 0); #region 动态类型 DefaultPostType = GetDefaultPostType(type); #endregion int PageSize = _PostPageSize; int pageIndex = Common.Globals.SafeInt(Fm["pageIndex"], 0); list = PostsBll.GetPostByType(UserId, ViewModel.ViewModelBase.GetStartPageIndex( PageSize, pageIndex), ViewModel.ViewModelBase.GetEndPageIndex(PageSize, pageIndex), DefaultPostType, YSWL.Components.MvcApplication.GetCurrentRoutePath(YSWL.Web.AreaRoute.MSNS), IncludeProduct); #region 静态化路径 string IsStatic = YSWL.MALL.BLL.SysManage.ConfigSystem.GetValueByCache("SNSIsStatic"); if (list != null && list.Count > 0) { foreach (var item in list) { if (item.Post != null && item.Post.Type == (int)YSWL.MALL.Model.SNS.EnumHelper.PostContentType.Product) { YSWL.MALL.Model.SNS.Products productModel = productBll.GetModelByCache(item.Post.TargetId); if (IsStatic != "true") { item.Post.Description = item.Post.Description.Replace("{ProductUrl}", (ViewBag.BasePath + "Product/Detail/" + item.Post.TargetId)); } else if (productModel != null) { item.Post.Description = item.Post.Description.Replace("{ProductUrl}", (String.IsNullOrWhiteSpace(productModel.StaticUrl) ? ViewBag.BasePath + "Product/Detail/" + item.Post.TargetId : productModel.StaticUrl)); } } if (item.Post != null && item.Post.Type == (int)YSWL.MALL.Model.SNS.EnumHelper.PostContentType.Blog) { YSWL.MALL.Model.SNS.UserBlog blogModel = blogBll.GetModelByCache(item.Post.TargetId); if (IsStatic != "true") { item.Post.Description = item.Post.Description.Replace("{BlogUrl}", (ViewBag.BasePath + "Blog/BlogDetail/" + item.Post.TargetId)); } else if (blogModel != null) { item.Post.Description = item.Post.Description.Replace("{BlogUrl}", (String.IsNullOrWhiteSpace(blogModel.StaticUrl) ? ViewBag.BasePath + "Blog/BlogDetail/" + item.Post.TargetId : blogModel.StaticUrl)); } } if (item.OrigPost != null && item.OrigPost.Type == (int)YSWL.MALL.Model.SNS.EnumHelper.PostContentType.Product) { YSWL.MALL.Model.SNS.Products productModel = productBll.GetModelByCache(item.OrigPost.TargetId); if (IsStatic != "true") { item.OrigPost.Description = item.OrigPost.Description.Replace("{ProductUrl}", (ViewBag.BasePath + "Product/Detail/" + item.OrigPost.TargetId)); } else if (productModel != null) { item.OrigPost.Description = item.OrigPost.Description.Replace("{ProductUrl}", (String.IsNullOrWhiteSpace(productModel.StaticUrl) ? ViewBag.BasePath + "Product/Detail/" + item.OrigPost.TargetId : productModel.StaticUrl)); } } if (item.OrigPost != null && item.OrigPost.Type == (int)YSWL.MALL.Model.SNS.EnumHelper.PostContentType.Blog) { YSWL.MALL.Model.SNS.UserBlog blogModel = blogBll.GetModelByCache(item.OrigPost.TargetId); if (IsStatic != "true") { item.OrigPost.Description = item.OrigPost.Description.Replace("{BlogUrl}", (ViewBag.BasePath + "Blog/BlogDetail/" + item.OrigPost.TargetId)); } else if (blogModel != null) { item.OrigPost.Description = item.OrigPost.Description.Replace("{BlogUrl}", (String.IsNullOrWhiteSpace(blogModel.StaticUrl) ? ViewBag.BasePath + "Blog/BlogDetail/" + item.OrigPost.TargetId : blogModel.StaticUrl)); } } } } #endregion if (currentUser != null) { ViewBag.CurrentUserID = currentUser.UserID; } return(PartialView(CurrentThemeViewPath + "/UserProfile/LoadPostData.cshtml", list)); }