public async Task <MyBlogCommonResponse <int> > AddBlogArticle([FromBody] BlogArticle blogArticle) { MyBlogCommonResponse <int> response = new MyBlogCommonResponse <int>(); try { blogArticle.ArticleCreateTime = DateTime.Now; blogArticle.ArticleVisitNumber = 0; var id = (await _blogArticleServices.Add(blogArticle)); response.success = id > 0; if (response.success) { response.data = id; response.message = "添加成功"; } else { response.message = "执行数据添加失败"; response.code = 500; } return(response); } catch (Exception ex) { response.message = ex.Message.ToString(); response.code = 500; return(response); } }
public ActionResult Add(BlogArticle blogArticle) { if (blogArticle.bID > 0) { BlogArticle model = BlogArticleServive.QueryWhere(a => a.bID == blogArticle.bID).FirstOrDefault(); if (model != null) { model.btitle = blogArticle.btitle; model.bcategory = blogArticle.bcategory; model.bcontent = blogArticle.bcontent; BlogArticleServive.Edit(model); BlogArticleServive.SaverChanges(); return(Content("<script type='text/javascript'>alert('厉害啦!更新成功!');window.location='/admin/BlogArticle/Index';</script>")); } else { return(Content("<script type='text/javascript'>alert('错啦错啦,没这个数据!');window.location='/admin/BlogArticle/Add';</script>")); } } else { blogArticle.bCreateTime = DateTime.Now; blogArticle.bsubmitter = "admin"; blogArticle.bUpdateTime = DateTime.Now; blogArticle.bRemark = string.Empty; BlogArticleServive.Add(blogArticle); BlogArticleServive.SaverChanges(); return(Content("<script type='text/javascript'>alert('添加成功!');window.location='/admin/BlogArticle/Add';</script>")); } }
public ActionResult Add(BlogArticle blogArticle) { blogArticle.bCreateTime = DateTime.Now; blogArticle.bsubmitter = "admin"; blogArticle.bUpdateTime = DateTime.Now; blogArticle.bRemark = string.Empty; iblog.Add(blogArticle); iblog.SaverChanges(); return(Content("ok:添加成功!")); }
public ActionResult Add(BlogArticle blogArticle) { blogArticle.create_time = DateTime.Now; blogArticle.submitter = "admin"; blogArticle.update_time = DateTime.Now; blogArticle.remark = string.Empty; BlogArticleServive.Add(blogArticle); BlogArticleServive.SaverChanges(); return(Content("ok:添加成功!")); }
public async Task <MessageModel <string> > Post([FromBody] BlogArticle blogArticle) { var data = new MessageModel <string>(); blogArticle.bCreateTime = DateTime.Now; blogArticle.bUpdateTime = DateTime.Now; blogArticle.IsDeleted = false; blogArticle.bcategory = "技术博文"; var id = (await _blogArticleServices.Add(blogArticle)); data.success = id > 0; if (data.success) { data.response = id.ObjToString(); data.msg = "添加成功"; } return(data); }
public async void Add_Blog_Test() { BlogArticle blogArticle = new BlogArticle() { bCreateTime = DateTime.Now, bUpdateTime = DateTime.Now, btitle = "xuint test title", bcontent = "xuint test content", bsubmitter = "xuint test submitter", }; var BId = await blogArticleServices.Add(blogArticle); Assert.True(BId > 0); }
public async Task <MessageModel <string> > Post([FromBody] BlogArticle request) { var data = new MessageModel <string>(); var id = await _blogArticleServices.Add(request); data.success = id > 0; if (data.success) { data.response = id.ObjToString(); data.msg = "添加成功"; } return(data); }
public async Task <bool> Inserts(String bsubmitter, String btitle, String bcategory, String bcontent, String bRemark) { BlogArticle blogArticle = new BlogArticle() { bsubmitter = bsubmitter, btitle = btitle, bcategory = bcategory, bcontent = bcontent, bRemark = bRemark, btraffic = 0, bcommentNum = 0, bUpdateTime = DateTime.Now, bCreateTime = DateTime.Now }; bool result = await blogArticleServices.Add(blogArticle) > 0?true:false; return(result); }
public async Task <object> TestMutiDBAPI() { // 从主库中,操作blogs var blogs = await _blogArticleServices.Query(d => d.bID == 1); var addBlog = await _blogArticleServices.Add(new BlogArticle() { }); // 从从库中,操作pwds var pwds = await _passwordLibServices.Query(d => d.PLID > 0); var addPwd = await _passwordLibServices.Add(new PasswordLib() { }); return(new { blogs, pwds }); }
public async Task <MessageModel> Add(BlogArticle model) { model.Id = 0; return(new MessageModel(await _BlogArticleServices.Add(model) > 0)); }