Ejemplo n.º 1
0
 public IActionResult Add(Model.Category ca)
 {
     if (ca.Id == 0)
     {
         ca.CreateDate = DateTime.Now;
         ca.ParentCate = "01";
         ca.CateNo     = cadal.GetCateNo("01", 2);
         cadal.Insert(ca);
         return(Json(new { status = "y", info = "新增分类成功!" }));
     }
     else
     {
         //只编辑分类名称
         Model.Category ca_indb = cadal.GetModel(ca.Id);
         ca_indb.CateName = ca.CateName;
         cadal.Update(ca_indb);
         return(Json(new { status = "y", info = "编辑分类成功!" }));
     }
 }
Ejemplo n.º 2
0
 public IActionResult Add(Model.Blog blog)
 {
     blog.CreateDate = DateTime.Now;
     if (blog.CateNo == "0")
     {
         //新分类,先增加
         string cateNo = catedal.GetCateNo("0", 2);
         catedal.Insert(new Model.Category()
         {
             CateName = blog.CateName, CateNo = cateNo, CreateDate = DateTime.Now, ParentCate = "0", Remark = ""
         });
         blog.CateNo = cateNo;
     }
     if (blog.Id == 0)
     {
         blogdal.Insert(blog);
         return(Json(new { status = "y", info = "博客新增成功!" }));
     }
     else
     {
         blogdal.Update(blog);
         return(Json(new { status = "y", info = "博客编辑成功!" }));
     }
 }