/// <summary> /// 获取评论分页数据 /// </summary> /// <returns></returns> public string GetCommentPageList() { try { int cid = Convert.ToInt32(Request["cid"]); int pageIndex = Convert.ToInt32(Request["pageIndex"] ?? "1"); int pageSize = Convert.ToInt32(Request["pageSize"] ?? "5"); ContentBLL bll = new ContentBLL(); SessionInfo info = (SessionInfo)Session["sessionInfo"]; int userid = 0; if (info != null) { userid = info.userModel.Id; } ContentPageModel <CommentModel> list = bll.GetCommentPageList(cid, pageIndex, pageSize, userid); list.pageThis = pageIndex; var res = JsonConvert.SerializeObject(list); return("success:" + res.ToString()); } catch (Exception ex) { Log.WriteFile(ex); return("faliure:失败"); } }
public ActionResult Edit(int ID) { var result = ContentBLL.GetContentByID(ID); SetViewBag(result.CategoryID); return(View(result)); }
/// <summary> /// 文章管理页面 /// </summary> /// <returns></returns> //[OutputCache(CacheProfile = "Long")] public string GetCList() { try { //搜索内容 string search = Request["txt_search"] ?? ""; //页码 int index = Convert.ToInt32(Request["index"] == "" || Request["index"] == null ? "1" : Request["index"]); //每页取几条数据 int page = Convert.ToInt32(Request["pagesize"]); //总数 int total = Convert.ToInt32(Request["Total"]); //类别id int typeId = Convert.ToInt32(Request["typeId"]); ContentBLL bll = new ContentBLL(); List <TypeModel> tlist = bll.GetTyleList(); TableModel <ContentModel> info = bll.GetContentList(search, index, page, total, typeId); var res = JsonConvert.SerializeObject(info); return("success:" + res.ToString()); } catch (Exception ex) { Log.WriteFile(ex); return("failure:失败"); } }
/// <summary> /// 编辑标签 /// </summary> /// <returns></returns> public string UpdateLabel() { try { string lid = Request["id"]; string name = Request["name"]; int id = 0; int.TryParse(lid, out id); ContentBLL bll = new ContentBLL(); if (id == 0) { int res = bll.AddLabel(name); if (res > 0) { return("success"); } } else { int res = bll.UpdateLabel(id, name); if (res > 0) { return("success"); } } return("failure:失败"); } catch (Exception ex) { Log.WriteFile(ex); return("failure:失败"); } }
public ActionResult Detail(int ID) { var content = ContentBLL.GetContentByID(ID); ViewBag.Tags = TagBLL.GetAllTag(ID); return(View(content)); }
/// <summary> /// 根据ID获取文章详情 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Detail(string id) { try { int cid = 0; int.TryParse(id, out cid); if (cid == 0) { return(Content("")); } UserBLL bll = new UserBLL(); ContentBLL cbll = new ContentBLL(); int addsee = cbll.AddSee(cid); ContentModel model = bll.GetContentById(cid); if (model == null) { return(Content("")); } return(View(model)); } catch (Exception ex) { Log.WriteFile(ex); return(new EmptyResult()); } }
public void ContentGetTreeByPropertyTest() { SettingUp(); var _Tree = new ContentBLL().GetTreeByContentProperty(D0.ContentPropertyID, _Cultures[0].CultureID, _CustomerUser.Id); Assert.IsNotNull(_Tree); Assert.IsTrue(_Tree[0].ContentPropertyID == D00.ContentPropertyID); Assert.IsTrue(_Tree[1].ContentPropertyID == D01.ContentPropertyID); Assert.IsTrue(_Tree[1].Items.Count == 3); }
public void ContentRootDelete() { SettingUp(); new ContentBLL().Delete(D01.ContentPropertyID, _CustomerUser.Id); var _List = new ContentBLL().GetRootChilds(D0.ContentPropertyID); Assert.IsNotNull(_List); Assert.IsTrue(_List.Count == 1); Assert.IsTrue(_List[0] == D00.ContentPropertyID); }
public void ContentGetMenuTest() { SettingUp(); new ContentBLL().InMenu(new data.binding.ContentBoolean { Boolean = true, ContentPropertyID = D01.ContentPropertyID, }, _CustomerUser.Id); var _Menu = new ContentBLL().GetMenu(_SiteID, _Cultures[0].CultureID, _CustomerUser.Id); Assert.IsNotNull(_Menu); Assert.IsTrue(_Menu[1].ContentPropertyID == D01.ContentPropertyID); }
public void ContentSaveTest() { SettingUp(); int _CPID1 = new ContentBLL().Save(new data.binding.ContentBinding { ContentPropertyAlias = "1", ContentPropertyType = data.binding.ContentPropertyType.LIST, SiteID = _SiteID }); Assert.IsNotNull(_CPID1); Assert.IsTrue(_CPID1 != 0); }
public void ContentGetByRoot() { using (var _c = new ApplicationDbContext()) { SettingUp(); var _Logger = new MyLogger(); _c.Database.Log = s => _Logger.Log("EFApp", s); TreeComplete(new ContentBLL().GetByRoot(_SiteID, null, D0.ContentPropertyAlias, _Cultures[0].Name, _c)); Assert.IsTrue(_Logger.NumberSQLQuery == 2); var _Model = new ContentBLL().GetByRoot(_SiteID, null, "una-cosa-loca-que-no-existe", _Cultures[0].Name, _c); Assert.IsTrue(_Model == null); } }
/// <summary> /// 回复评论 /// </summary> /// <returns></returns> public string HuiFu() { try { ContentBLL bll = new ContentBLL(); return("success"); } catch (Exception ex) { Log.WriteFile(ex); return("faliure:失败"); } }
/// <summary> /// 根据Id获取文章 /// </summary> /// <returns></returns> public string GetContentById() { try { int id = Convert.ToInt32(Request["contentId"]); ContentBLL bll = new ContentBLL(); ContentModel model = bll.GetContentById(id); return("success:" + JsonConvert.SerializeObject(model).ToString()); } catch (Exception) { return("failure:失败"); } }
/// <summary> /// 删除文章 /// </summary> /// <returns></returns> public string DeleteContent() { try { int id = Convert.ToInt32(Request["contentId"]); ContentBLL bll = new ContentBLL(); int res = bll.DeleteContent(id); if (res > 0) { return("success"); } return("failure:删除失败"); } catch (Exception) { throw; } }
public void ContentRootMove() { SettingUp(); var _Move = new ContentMoveBinding { ContentPropertyID = D012.ContentPropertyID, ContentPropertyParentID = 0, Index = 1 }; new ContentBLL().Move(_Move, _CustomerUser.Id); var _List = new ContentBLL().GetRootChilds(D012.ContentPropertyID); Assert.IsTrue(_List.Count == 1); _List = new ContentBLL().GetRootParentsID(D012.ContentPropertyID); Assert.IsTrue(_List.Count == 1); _List = new ContentBLL().GetRootParentsID(D0120.ContentPropertyID); Assert.IsTrue(_List.Count == 2); }
// // GET: /Content/ /// <summary> /// 新增查看数 /// </summary> /// <returns></returns> public string AddSee() { try { int cid = Convert.ToInt32(Request["contentId"]); ContentBLL bll = new ContentBLL(); int res = bll.AddSee(cid); if (res > 0) { return("success"); } return("failure"); } catch (Exception ex) { Log.WriteFile(ex); return("failure"); } }
// GET: Content public ActionResult Index(int page = 1, int pageSize = 10) { var content = ContentBLL.ListAllPaging(page, pageSize); int totalRecord = 0; ViewBag.Total = totalRecord; ViewBag.Page = page; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(content)); }
/// <summary> /// 反对评论数 /// </summary> /// <returns></returns> public string FanDui() { try { int commentId = Convert.ToInt32(Request["commentId"]); SessionInfo info = (SessionInfo)Session["sessionInfo"]; ContentBLL bll = new ContentBLL(); int res = bll.FanDui(commentId, info.userModel.Id); if (res > 0) { return("success:" + res.ToString()); } return("faliure"); } catch (Exception ex) { Log.WriteFile(ex); return("faliure"); } }
/// <summary> /// 检查类别是否存在 /// </summary> /// <returns></returns> public string CheckType() { try { string name = Request["name"]; ContentBLL bll = new ContentBLL(); bool check = bll.CheckType(name); if (check) { return("success:ok"); } else { return("success:nook"); } } catch (Exception) { throw; } }
public ActionResult Tag(string tagId, int page = 1, int pageSize = 10) { var model = ContentBLL.ListAllByTag(tagId, page, pageSize); int totalRecord = 0; ViewBag.Total = totalRecord; ViewBag.Page = page; ViewBag.Tag = TagBLL.GetTag(tagId); int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(model)); }
public void ContentRootAdd() { SettingUp(); var _Model = new data.binding.ContentBinding { ContentPropertyAlias = "0-1-2-1", ContentPropertyType = data.binding.ContentPropertyType.LIST, SiteID = _SiteID, ContentPropertyParentID = D012.ContentPropertyID }; var _ID = new ContentBLL().Save(_Model); var _List = new ContentBLL().GetRootParentsID(_ID); Assert.IsTrue(_List.Count == 4); //UPDATING _Model.ContentPropertyID = _ID; new ContentBLL().Save(_Model); _List = new ContentBLL().GetRootParentsID(_ID); Assert.IsTrue(_List.Count == 4); }
public void SiteImportFromFileTest() { string _Content = System.IO.File.ReadAllText("Site.json"); byte[] toEncodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(_Content); _Content = "64base," + System.Convert.ToBase64String(toEncodeAsBytes); var _NewSiteID = new SiteBLL().Import(new data.binding.FileRead { FileContent = _Content, FileName = "Site.json" }); Assert.IsNotNull(_NewSiteID); Assert.IsTrue(_NewSiteID != 0); //VERIFY ROOTS var _Tree = new ContentBLL().GetContent(_NewSiteID, null, "home", "es"); var _TreeRoots = new ContentBLL().GetByRoot(_NewSiteID, null, "home", "es"); Assert.IsNotNull(_Tree); Assert.IsNotNull(_TreeRoots); Assert.IsTrue(_Tree.Items.Count == _TreeRoots.Items.Count); new SiteBLL().Delete(_NewSiteID); }
public string PingLunTiTiao() { try { string text = Request["text"]; text = text.Replace("<", "<"); text = text.Replace(">", ">"); int cid = Convert.ToInt32(Request["cid"]); int pageIndex = Convert.ToInt32(Request["pageIndex"] ?? "1"); int pageSize = Convert.ToInt32(Request["pageSize"] ?? "5"); SessionInfo user = Session["sessionInfo"] as SessionInfo; ContentBLL bll = new ContentBLL(); CommentModel model = new CommentModel() { ContentId = cid, Text = text, Time = DateTime.Now, UserId = user.userModel.Id, ZhiChi = 0, FanDui = 0 }; int res = bll.PingLunTiTiao(model); if (res > 1) { UserBLL ubll = new UserBLL(); ContentPageModel <CommentModel> list = ubll.GetComment(cid, pageIndex, pageSize); list.pageThis = pageIndex; return("success:" + JsonConvert.SerializeObject(list).ToString()); } return("failure:评论失败...."); } catch (Exception ex) { Log.WriteFile(ex); return("failure:评论出错...."); } }
public ActionResult Create(ContentModel contentModel) { if (ModelState.IsValid) { var session = Session[Common.CommonConstants.USER_SESSION] as UserLogin; contentModel.CreatedBy = session.UserName; var culture = Session[CommonConstants.CURRENT_CULTURE]; contentModel.Language = culture.ToString(); var content = new Content { ID = contentModel.ID, Name = contentModel.Name, MetaTitle = contentModel.MetaTitle, Description = contentModel.Description, Image = contentModel.Image, CategoryID = contentModel.CategoryID, Detail = HttpUtility.HtmlEncode(contentModel.Detail), Warrantly = contentModel.Warrantly, CreatedBy = contentModel.CreatedBy, MetaKeywords = contentModel.MetaKeywords, MetaDescriptions = contentModel.MetaDescriptions, Status = contentModel.Status, Tags = contentModel.Tags, }; var result = ContentBLL.InsertContent(content); if (result > 0) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Thêm nội dung tin tức không thành công"); } } SetViewBag(); return(View(contentModel)); }
private void SettingUp() { D0 = new data.binding.ContentBinding { ContentPropertyAlias = "0", ContentPropertyType = data.binding.ContentPropertyType.LIST, SiteID = _SiteID }; D0.ContentPropertyID = new ContentBLL().Save(D0); D00 = new data.binding.ContentBinding { ContentPropertyAlias = "0-0", ContentPropertyType = data.binding.ContentPropertyType.TXT, SiteID = _SiteID, ContentPropertyParentID = D0.ContentPropertyID }; D00.ContentPropertyID = new ContentBLL().Save(D00); D01 = new data.binding.ContentBinding { ContentPropertyAlias = "0-1", ContentPropertyType = data.binding.ContentPropertyType.LIST, SiteID = _SiteID, ContentPropertyParentID = D0.ContentPropertyID }; D01.ContentPropertyID = new ContentBLL().Save(D01); D010 = new data.binding.ContentBinding { ContentPropertyAlias = "0-1-0", ContentPropertyType = data.binding.ContentPropertyType.TXT, SiteID = _SiteID, ContentPropertyParentID = D01.ContentPropertyID }; D010.ContentPropertyID = new ContentBLL().Save(D010); D011 = new data.binding.ContentBinding { ContentPropertyAlias = "0-1-1", ContentPropertyType = data.binding.ContentPropertyType.TXT, SiteID = _SiteID, ContentPropertyParentID = D01.ContentPropertyID }; D011.ContentPropertyID = new ContentBLL().Save(D011); D012 = new data.binding.ContentBinding { ContentPropertyAlias = "0-1-2", ContentPropertyType = data.binding.ContentPropertyType.LIST, SiteID = _SiteID, ContentPropertyParentID = D01.ContentPropertyID }; D012.ContentPropertyID = new ContentBLL().Save(D012); D0120 = new data.binding.ContentBinding { ContentPropertyAlias = "0-1-2-0", ContentPropertyType = data.binding.ContentPropertyType.TXT, SiteID = _SiteID, ContentPropertyParentID = D012.ContentPropertyID }; D0120.ContentPropertyID = new ContentBLL().Save(D0120); var _Tree = new ContentBLL().GetTree(_SiteID, _Cultures[0].CultureID, _CustomerUser.Id); new ContentBLL().SaveTree(new data.binding.ContentTreeBinding { CultureID = _Cultures[0].CultureID, Items = _Tree, SiteID = _SiteID }, _CustomerUser.Id); Assert.IsNotNull(_Tree); }
// GET: Admin/Content public ActionResult Index() { var contents = ContentBLL.GetAllContent(); return(View(contents)); }
public void ContentRootDelete() { SettingUp(); new ContentBLL().Delete(D01.ContentPropertyID,_CustomerUser.Id); var _List = new ContentBLL().GetRootChilds(D0.ContentPropertyID); Assert.IsNotNull(_List); Assert.IsTrue(_List.Count == 1); Assert.IsTrue(_List[0] == D00.ContentPropertyID); }