Ejemplo n.º 1
0
        /// <summary>
        /// 创建文章分类
        /// </summary>
        /// <param name="model">新建文章分类模型</param>
        public void CreateArticleCategory(NewArticleCategoryModel model)
        {
            IRepository <ArticleCategory> articleRep = Factory.Factory <IRepository <ArticleCategory> > .GetConcrete <ArticleCategory>();

            try
            {
                if (model.ParentID.Equals(Guid.Empty) || model.Deepth == 1)
                {
                    articleRep.Add(new ArticleCategory(model.CategoryName, model.Description, model.Icon, model.Priority));
                }
                else
                {
                    articleRep.Add(new ArticleCategory(model.CategoryName, model.Description, model.Icon, model.Priority, model.Deepth, model.ParentID));
                }

                articleRep.PersistAll();
            }

            catch { }
        }
Ejemplo n.º 2
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            NewArticleCategoryModel model = new NewArticleCategoryModel();

            model.CategoryName = TBnewCategory.Text.ToString().Trim();

            string t = ArticleCategory.SelectedItem.Value.ToString();

            if (t == Guid.Empty.ToString())
            {
                model.Deepth = 1;
            }
            else
            {
                model.Deepth = ++new CategoryService().GetArticleCategoryById(new Guid(t)).Deepth;
            }
            model.Description = TBdescr.Text.Trim().ToString();
            model.Icon        = String.Empty;
            model.ParentID    = new Guid(ArticleCategory.SelectedItem.Value.ToString());
            model.Priority    = System.UInt16.Parse(TByouxianji.Text.Trim().ToString());
            new CategoryService().CreateArticleCategory(model);
            Response.Write("<script>alert('添加成功')</script>");
        }