public JsonResult DeletePost() { var id = RequestHelper.GetValue("id"); if (string.IsNullOrEmpty(id)) { return(Json(new { result = false }, JsonRequestBehavior.DenyGet)); } var result = NoticeService.Delete(id); LogService.Info($"NoticeService.Delete >>> {result} --- {id}"); return(Json(new { result = result }, JsonRequestBehavior.DenyGet)); }
public ActionResult List() { ViewBag.NoticeInfo = Tuple.Create(string.Empty, string.Empty, 0); string guid = Controleng.Common.CECRequest.GetQueryString("guid"); string m = Controleng.Common.CECRequest.GetQueryString("m").ToLower(); if (m == "delete") { //删除 NoticeService.Delete(guid); //跳转到list Response.Redirect("List"); Response.End(); } if (!string.IsNullOrEmpty(guid)) { ViewBag.NoticeInfo = NoticeService.Get(guid); } if (HttpContext.Request.HttpMethod == "POST") { bool errors = false; string title = Request.Form["title"]; string url = Request.Form["url"]; int sort = Controleng.Common.Utils.StrToInt(Request.Form["sort"], 0); if (string.IsNullOrEmpty(title)) { errors = true; ModelState.AddModelError("title", "标题不能为空"); } if (string.IsNullOrEmpty(url)) { errors = true; ModelState.AddModelError("url", "链接不能为空"); } if (!errors) { NoticeService.Update(title, url, sort, guid); //跳转到list Response.Redirect("List"); Response.End(); } } var noticeList = NoticeService.List(); ViewBag.NoticeList = noticeList; return View(); }
/// <summary> /// 生成通知 /// </summary> /// <param name="sender">关注实体</param> /// <param name="eventArgs">事件参数</param> void FollowNoticeModule_After(FollowEntity sender, CommonEventArgs eventArgs) { if (EventOperationType.Instance().Create() == eventArgs.EventOperationType) { if (sender.IsQuietly) { return; } IUserService userService = DIContainer.Resolve <IUserService>(); //关注用户 IUser user = userService.GetUser(sender.UserId); if (user == null) { return; } IUser followedUser = userService.GetUser(sender.FollowedUserId); if (followedUser == null) { return; } NoticeService service = new NoticeService(); Notice notice = Notice.New(); notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.TemplateName = "FollowUser"; notice.UserId = followedUser.UserId; notice.LeadingActorUserId = user.UserId; notice.LeadingActor = user.DisplayName; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(user.UserName)); notice.RelativeObjectId = followedUser.UserId; notice.RelativeObjectName = followedUser.DisplayName; notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(followedUser.UserName)); service.Create(notice); } else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { NoticeService service = new NoticeService(); IEnumerable <Notice> notices = service.GetTops(sender.FollowedUserId, 20).Where(n => n.TemplateName == "FollowUser").Where(n => n.LeadingActorUserId == sender.UserId); foreach (var notice in notices) { service.Delete(notice.Id); } } }
public void ProcessRequest(HttpContext context) { NoticeService noticeService = new NoticeService(); context.Response.ContentType = "text/plain"; if (context.Request["NoticeId"] != null)//删除单个数据 { int uid = Int32.Parse(context.Request["NoticeId"]); bool b = noticeService.Delete(uid); context.Response.Write(b); context.Response.End(); } else //批量删除数据 { string nids = context.Request["nids"]; bool b1 = noticeService.DeleteList(nids); context.Response.Write(b1); context.Response.End(); } }
public async Task <ActionResponse> DeletePost(Notice post) { return(new ActionResponse(await _noticeService.Delete(post.Id))); }