public ArticleCategoryDetailsModel GetArticleCategoryById(Guid CategoryID) { IRepository <ArticleCategory> categoryRep = Factory.Factory <IRepository <ArticleCategory> > .GetConcrete <ArticleCategory>(); ArticleCategory tmp = null; ArticleCategoryDetailsModel target = null; try { //tmp = categoryRep.Find(new Specification<ArticleCategory>(c => c.Name == name)); target = new ArticleCategoryDetailsModel(); tmp = categoryRep.GetByKey(CategoryID); if (tmp == null) { return(null); } target.CategoryName = tmp.Name; target.Deepth = tmp.Deepth; target.Description = tmp.Description; target.Icon = tmp.Icon; target.ParentID = tmp.ParentID; target.Priority = tmp.Priority; target.CategoryID = CategoryID; } catch { return(target); } return(target); }
/// <summary> /// 修改文章分类 /// </summary> /// <param name="cid">编号</param> public void UpdateArticleCategory(ArticleCategoryDetailsModel model) { IRepository <ArticleCategory> categoryRep = Factory.Factory <IRepository <ArticleCategory> > .GetConcrete <ArticleCategory>(); try { ArticleCategory mymodel = categoryRep.GetByKey(model.CategoryID); mymodel.Deepth = model.Deepth; mymodel.Description = model.Description; mymodel.Icon = model.Icon; mymodel.Name = model.CategoryName; mymodel.ParentID = model.ParentID; mymodel.Priority = model.Priority; categoryRep.Update(mymodel); categoryRep.PersistAll(); } catch { } }
protected void Button2_Click(object sender, EventArgs e) { ArticleCategoryDetailsModel model = new ArticleCategoryDetailsModel(); model.CategoryName = TBnewCategory.Text.Trim().ToString(); model.Description = TBdescr.Text.Trim().ToString(); model.Priority = System.UInt16.Parse(TByouxianji.Text.Trim().ToString()); model.CategoryID = new Guid(Label1.Text.ToString()); model.ParentID = new Guid(ArticleCategory.SelectedItem.Value.ToString()); string t = ArticleCategory.SelectedItem.Value.ToString(); if (t == Guid.Empty.ToString()) { model.Deepth = 1; } else { model.Deepth = ++new CategoryService().GetArticleCategoryById(new Guid(t)).Deepth; } new CategoryService().UpdateArticleCategory(model); Response.Write("<script>alert('修改成功')</script>"); }
/// <summary> /// 按分类名称获取文章信息 /// </summary> /// <param name="name">分类名称</param> /// <returns>文章分类信息</returns> public ArticleCategoryDetailsModel GetArticleCategoryByName(string name) { IRepository <ArticleCategory> categoryRep = Factory.Factory <IRepository <ArticleCategory> > .GetConcrete <ArticleCategory>(); ArticleCategory tmp = null; ArticleCategoryDetailsModel target = new ArticleCategoryDetailsModel(); try { tmp = categoryRep.Find(new Specification <ArticleCategory>(c => c.Name == name)); target.CategoryID = tmp.Id; target.CategoryName = tmp.Name; target.Deepth = tmp.Deepth; target.Description = tmp.Description; target.Icon = tmp.Icon; target.ParentID = tmp.ParentID; target.Priority = tmp.Priority; } catch { } return(target); }