//我发布的通知 public ActionResult getReleaseList(NoticeCondition condition) { User user = TheApp.currentUser; if (user == null) { return(Redirect("/Home/Login")); } int pagesize = int.Parse(Request["rows"]); int pagenum = int.Parse(Request["page"]); if (condition == null) { condition = new NoticeCondition(); } NoticeDao dao = new NoticeDao(); int total; List <Notice> list = dao.getRelease(user.Id, pagenum, pagesize, out total, condition); dao.Dispose(); JsonData data = new JsonData(); data.rows = list; data.total = total; return(Json(data)); }
public ActionResult ReleasePost(string title, string content) { MyJsonResult result = new MyJsonResult(); User user = TheApp.currentUser; if (user == null) { return(Redirect("/Home/Login")); } if (user.Role != Role.Admin) { result.message = "您不是管理员,没有权限发布通知!"; return(Json(result)); } if (user.theCounty.Level == (int)Level.Town) { result.message = "您是乡镇管理员无法发布通知!"; return(Json(result)); } if (string.IsNullOrEmpty(title)) { result.message = "请输入通知标题!"; return(Json(result)); } if (string.IsNullOrEmpty(content)) { result.message = "请输入通知内容!"; return(Json(result)); } Notice notice = new Notice(); notice.Title = title; notice.Content = content; notice.Sender = user.Id; notice.CreateTime = DateTime.Now; NoticeDao dao = new NoticeDao(); dao.Release(notice); dao.Dispose(); result.success = true; return(Json(result)); }
public ActionResult getNoticeList(int pagenum, int pagesize, string userId, string type) { List <XinFangAndroid.Adapter.Notice> andNoticeList = new List <XinFangAndroid.Adapter.Notice>(); MyJsonResult result = new MyJsonResult(); pagenum = pagenum == 0 ? 1 : pagenum; pagesize = pagesize == 0 ? 5 : pagesize; //string type = Request.Form["type"]; //通知类型:1: 我发布的 2: 我收到的 if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(type)) { result.message = "参数错误"; return(Json(result)); } int count; if (int.Parse(type) == 1) { NoticeDao dao = new NoticeDao(); List <Notice> list = dao.getRelease(int.Parse(userId), pagenum, pagesize, out count, null); foreach (var item in list) { XinFangAndroid.Adapter.Notice note = new XinFangAndroid.Adapter.Notice(item.Id, item.Sender, item.Title, item.Content, item.CreateTime); andNoticeList.Add(note); } dao.Dispose(); result.success = true; result.data = andNoticeList; return(Json(result)); } else if (int.Parse(type) == 2) { NoticeReceiverDao dao = new NoticeReceiverDao(); List <NoticeReceiver> list = dao.getReceiveNotice(int.Parse(userId), pagenum, pagesize, null); dao.Dispose(); result.success = true; result.data = list; return(Json(result)); } else { throw new ApplicationException("类型错误"); } }
public ActionResult ReleaseDetail() { string idStr = Request["id"]; if (string.IsNullOrEmpty(idStr)) { throw new ApplicationException("未传入指定参数"); } int id = int.Parse(idStr); NoticeDao dao = new NoticeDao(); Notice notice = dao.get(id); dao.Dispose(); if (notice == null) { throw new ApplicationException("未找到该通知信息" + id); } return(View(notice)); }