private BlogSysCategory validate( BlogSysCategory c ) { if (c == null) c = new BlogSysCategory(); c = ctx.PostValue( c ) as BlogSysCategory; if (strUtil.IsNullOrEmpty( c.Name )) errors.Add( lang( "exName" ) ); return c; }
public virtual List<BlogSysCategory> GetForDroplist() { List<BlogSysCategory> list = this.GetAll(); BlogSysCategory c = new BlogSysCategory(); c.Name = lang.get( "plsSelect" ) + "..."; list.Insert( 0, c ); return list; }
public virtual List <BlogSysCategory> GetForDroplist() { List <BlogSysCategory> list = this.GetAll(); BlogSysCategory c = new BlogSysCategory(); c.Name = lang.get("plsSelect") + "..."; list.Insert(0, c); return(list); }
public void Edit( int id ) { target( Update, id ); BlogSysCategory c = categoryService.GetById( id ); if (c == null) { echoRedirect( lang( "exDataNotFound" ) ); return; } bind( "category", c ); }
public void Delete( int id ) { BlogSysCategory c = categoryService.GetById( id ); if (c == null) { echoRedirect( lang( "exDataNotFound" ) ); return; } db.delete( c ); log( SiteLogString.DeleteBlogSysCategory(), c ); redirect( List ); }
public void Create() { BlogSysCategory c = validate( null ); if (ctx.HasErrors) { run( Add ); return; } db.insert( c ); log( SiteLogString.InsertBlogSysCategory(), c ); echoToParentPart( lang("opok") ); }
private string getSysCategoryName(BlogPost post) { if (post.SysCategoryId == 0) { return(""); } BlogSysCategory c = categoryService.GetById(post.SysCategoryId); if (c == null) { return(""); } return(c.Name); }
private List<BlogSysCategory> addSelectInfo( List<BlogSysCategory> categories ) { BlogSysCategory category = new BlogSysCategory(); category.Id = -1; category.Name = lang( "setCategory" ); BlogSysCategory nullCat = new BlogSysCategory(); nullCat.Id = zeroCatId; nullCat.Name = "--无分类--"; List<BlogSysCategory> list = new List<BlogSysCategory>(); list.Add( category ); list.Add( nullCat ); foreach (BlogSysCategory cat in categories) { list.Add( cat ); } return list; }
public void Update( int id ) { BlogSysCategory c = categoryService.GetById( id ); if (c == null) { echoRedirect( lang( "exDataNotFound" ) ); return; } c = validate( c ); if (ctx.HasErrors) { run( Edit, id ); return; } db.update( c ); log( SiteLogString.UpdateBlogSysCategory(), c ); echoToParentPart( lang( "opok" ) ); }
public virtual void SaveSort() { int id = ctx.PostInt( "id" ); String cmd = ctx.Post( "cmd" ); BlogSysCategory target = categoryService.GetById( id ); List<BlogSysCategory> list = categoryService.GetAll(); if (cmd == "up") { new SortUtil<BlogSysCategory>( target, list ).MoveUp(); echoJsonOk(); } else if (cmd == "down") { new SortUtil<BlogSysCategory>( target, list ).MoveDown(); echoJsonOk(); } else { echoError( lang( "exUnknowCmd" ) ); } }
private List <BlogSysCategory> addSelectInfo(List <BlogSysCategory> categories) { BlogSysCategory category = new BlogSysCategory(); category.Id = -1; category.Name = lang("setCategory"); BlogSysCategory nullCat = new BlogSysCategory(); nullCat.Id = zeroCatId; nullCat.Name = "--无分类--"; List <BlogSysCategory> list = new List <BlogSysCategory>(); list.Add(category); list.Add(nullCat); foreach (BlogSysCategory cat in categories) { list.Add(cat); } return(list); }
//-------------------------------------------------------------------------------------------- public void Recent() { ctx.Page.Title = alang("allBlogPost"); set("blogLink", to(Index)); DataPage <BlogPost> blogs = null; String qword = ctx.Get("qword"); int qtype = ctx.GetInt("qtype"); int categoryId = ctx.GetInt("cid"); if (strUtil.HasText(qword) && qtype > 0) { qword = strUtil.SqlClean(qword, 20); String condition = ""; if (qtype == 1) { condition = "Title like '%" + qword + "%'"; } else if (qtype == 2) { User user = userService.GetByName(qword); if (user == null) { echoRedirect(lang("exUserNotFound") + " : " + qword); return; } condition = "CreatorId=" + user.Id; } else { echoRedirect(lang("exop")); return; } blogs = sysblogService.GetSysPageBySearch(condition); set("listName", "搜索结果"); } else if (categoryId > 0) { blogs = sysblogService.GetSysPageByCategory(categoryId, 30); BlogSysCategory c = categoryService.GetById(categoryId); if (c == null) { set("listName", "分类不存在,没有结果"); } else { set("listName", c.Name); } } else { blogs = sysblogService.GetSysPage(30); set("listName", alang("allBlogPost")); } bindList("list", "post", blogs.Results, bindLink); set("page", blogs.PageBar); set("recentLink", to(Recent)); }
private void log( String msg, BlogSysCategory c ) { String dataInfo = "{Id:" + c.Id + ", Name:'" + c.Name + "'}"; logService.Add( (User)ctx.viewer.obj, msg, dataInfo, typeof( BlogSysCategory ).FullName, ctx.Ip ); }