コード例 #1
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"));
 }
コード例 #2
0
        /// <summary>
        /// 点击录入按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button2_Click(object sender, EventArgs e)
        {
            Blog model = new Blog();

            model.name   = textBox1.Text;
            model.author = textBox2.Text;
            model.date   = dateTimePicker1.Text; //XX年XX月XX日
            BlogDAL.Add(model);
            ShowDataGird();
        }
コード例 #3
0
 public IActionResult Add(BlogEntity blogEntity)
 {
     if (string.IsNullOrEmpty(this.User.Identity.Name))
     {
         return(Content("您尚未登录用户"));
     }
     if (string.IsNullOrEmpty(blogEntity.BlogID))
     {
         //新增
         blogEntity.BlogID      = Guid.NewGuid().ToString();
         blogEntity.CreatedTime = DateTime.Now;
         blogEntity.CreatedBy   = this.User.Claims.First().Value;
         blogDAL.Add(blogEntity);
     }
     return(Redirect("/Blog/Index"));
 }