public void ProcessRequest(HttpContext context) { //string a = context.Session["admin"].ToString(); context.Response.ContentType = "text/plain"; NoticeService noticeService = new NoticeService(); Notice notice = new Notice(); notice.notitle = context.Request["notitle1"]; notice.nocontent = context.Request["nocontent1"]; notice.adminid = 1; notice.notime = DateTime.Now; bool b; if (noticeService.Add(notice) > 0) { b = true; } else { b = false; } context.Response.Write(b); context.Response.End(); }
public JsonResult AddPost() { var id = Guid.NewGuid().ToString("n"); var title = RequestHelper.GetValue("title"); var contents = RequestHelper.GetValue("contents"); if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(contents)) { return(Json(new { result = false, info = "缺少标题,内容。" }, JsonRequestBehavior.DenyGet)); } var dto = new NoticeDto() { Id = id, CreateTime = DateTime.Now, Title = title, Contents = contents, IsDelete = 0 }; var result = NoticeService.Add(dto); LogService.Info($"NoticeService.Add >>> {result} --- {id}:{title}"); return(Json(new { result = result }, JsonRequestBehavior.DenyGet)); }