Exemplo n.º 1
0
        public IActionResult Add(Model.Blog m)
        {
            m.CreateDate = DateTime.Now;
            if (m.CaName == null)
            {
                m.CaName = "默认";
            }
            Model.Category ca = cadal.GetModelByBh(m.CaBh);
            if (ca != null)
            {
                m.CaName = ca.CaName;
            }

            if (m.Id == 0)
            {
                //新增
                dal.Insert(m);
            }
            else
            {
                //修改
                dal.Update(m);
            }
            return(Redirect("/Adnn1n/Blog/Index"));
        }
Exemplo n.º 2
0
 public IActionResult Add(Model.Blog m)
 {
     Model.Category ca = cadal.GetModelByBh(m.CaBh);
     if (ca != null)
     {
         m.CaName = ca.CaName;
     }
     if (m.Id == 0)
     {
         dal.Insert(m);
     }
     else
     {
         m.updatetime = DateTime.Now;
         dal.Update(m);
     }
     return(Redirect("/Admin/Blog/Index"));
 }
Exemplo n.º 3
0
        public IActionResult Mod(int pid, string caname, int id)
        {
            Model.Category ca = dal.GetModel(id);
            if (ca == null)
            {
                return(Json(new { status = "n", info = "分类ID传入错误!" }));
            }

            string bh  = ca.Bh;
            string pbh = ca.Pbh;

            int source_pid = ca.Pbh == "0" ? 0 :dal.GetModelByBh(ca.Pbh).Id; //分类原本的父级ID

            Model.Category pca = dal.GetModel(pid);
            if (pca != null)
            {
                if (pca.Id != source_pid)
                {
                    //需要修改父级分类,重新生成编号
                    pbh = pca.Bh;
                    bh  = dal.GenBH(pbh, 2);
                }
            }
            else if (pid == 0)
            {
                //设置为顶级分类
                pbh = "0";
                bh  = dal.GenBH(pbh, 2);
            }

            ca.CaName = caname;
            ca.Bh     = bh;
            ca.Pbh    = pbh;
            bool b = dal.Update(ca);

            if (b)
            {
                return(Json(new { status = "y", info = "分类修改成功!" }));
            }
            else
            {
                return(Json(new { status = "n", info = "分类修改失败,请联系管理员!" }));
            }
        }
Exemplo n.º 4
0
 public IActionResult Add(Model.Blog m)
 {
     Model.Category ca = cadal.GetModelByBh(m.cabh);
     if (ca != null)
     {
         m.caname = ca.caname;
     }
     if (m.id == 0)
     {
         //新增
         dal.insert(m);
     }
     else
     {
         //修改
         dal.update(m);
     }
     return(Redirect("/Admin/Blog/Index"));
 }
Exemplo n.º 5
0
        public IActionResult Add(Model.Blog m)
        {
            Model.Category ca = cadal.GetModelByBh(m.cabh);
            if (ca != null)
            {
                m.caname = ca.CaName;
            }

            if (m.id == 0)
            {
                //新增
                m.createdate = DateTime.Now;
                dal.Add(m);
            }
            else
            {
                //修改
                m.updatetime = DateTime.Now;
                dal.Update(m);
            }
            return(Redirect("/Adnn1n/Blog/Index"));
        }