public void AddArticle(HttpContext context) { string cateid = context.Request["cateid"]; string title = context.Request["title"]; string content = context.Request["content"]; Article entity = new Article(); entity.Cate_id = int.Parse(cateid); entity.Title = title; entity.Content = content; entity.Update_Time = DateTime.Now; //从session中获取当前用户 User curUser = context.Session["CurUser"] as User; entity.Create_User = curUser.ID; bool res = ArticleMgr.Add(entity); if (res) { context.Response.Write("{\"status\":true}"); } else { context.Response.Write("{\"status\":false}"); } }
/// <summary> /// 保存文章 新增/修改 /// </summary> /// <param name="article"></param> /// <returns></returns> public JsonResult SaveArticle(Article article) { bool res = false; article.Update_Time = DateTime.Now; article.Create_User = ContextObjects.CurrentUser.ID; //id为-1时,即新增 if (article.ID == -1) { res = ArticleMgr.Add(article); } else { res = ArticleMgr.Update(article); } return(Json(res)); }