示例#1
0
        public IActionResult Add(BlogModel blog)
        {
            CategoryModel model = CategoryDAL.GetCategoryByBh(blog.CBh);

            if (blog.Bid == 0)
            {
                if (model != null)
                {
                    blog.CName = model.CName;
                    blog.CBh   = model.CBh;
                }
                blog.CreateDate = DateTime.Now;
                blog.Aid        = 1;
                BlogDAL.Insert(blog);
            }
            else
            {
                if (model != null)
                {
                    blog.CName = model.CName;
                    blog.CBh   = model.CBh;
                }
                BlogDAL.Update(blog);
            }
            return(Redirect("/Areas/Home/BlogList"));
        }
示例#2
0
 public IActionResult Add(BLOG blog)
 {
     if (blog.Id == 0)
     {
         var Type = _CategoryDAL.GetOne(int.Parse(blog.CategoryTypeId));
         if (Type != null)
         {
             blog.CategoryTypeName = Type.CName;
         }
         blog.Content_Md = blog.Content;
         blog.Remark     = "";
         blog.BlogId     = Guid.NewGuid().ToString();
         blog.UserID     = "100";
         _BlogDAL.Add(blog);
     }
     else
     {
         blog.Content_Md = blog.Content;
         var Type = _CategoryDAL.GetOne(int.Parse(blog.CategoryTypeId));
         if (Type != null)
         {
             blog.CategoryTypeName = Type.CName;
         }
         blog.Content_Md = blog.Content;
         _BlogDAL.Update(blog);
     }
     return(Redirect("/Admin/Home/Default"));
 }
        public IActionResult Update(BlogEntity blogEntity)
        {
            BlogEntity m = null;

            if (!string.IsNullOrEmpty(blogEntity.BlogID))
            {
                //修改
                m = blogDAL.GetBlogByID(blogEntity.BlogID);
                blogEntity.BlogTitle    = m.BlogTitle;
                blogEntity.BlogContent  = blogEntity.BlogContent;
                blogEntity.ModifiedTime = DateTime.Now;
                blogEntity.ModifiedBy   = this.User.Identity.Name;
                blogDAL.Update(blogEntity);
            }
            return(Redirect("/Blog/Index"));
        }
示例#4
0
 public IActionResult ShowBlogDetails(int?Id)
 {
     ViewBag.CategoryList = _CATEGORYDAL.GetList();
     ViewBag.BlogDAL      = _BlogDAL;
     if (Id == null)
     {
         return(Content("找不到该条博客数据!"));
     }
     else
     {
         BLOG bLOG = _BlogDAL.GetOne(Id.Value);
         if (bLOG == null)
         {
             return(Content("找不到该条博客数据!"));
         }
         bLOG.Visit += 1;
         _BlogDAL.Update(bLOG);
         return(View(bLOG));
     }
 }
示例#5
0
        public IActionResult Add(Blog bo)
        {
            Category ca = cadal.GetModelByBh(bo.CaBh);

            if (ca != null)
            {
                bo.CaName = ca.CaName;
            }
            if (bo.Id == 0)
            {
                //新增
                bodal.Insert(bo);
            }
            else
            {
                //修改
                bodal.Update(bo);
            }

            return(Redirect("/Adnn1n/Blog/Index"));
        }