public ActionResult Edit(Topic model) { var str = Helper.HtmlHelper.TransStringToHtml(model.Content); str = Helper.HtmlHelper.TransHtmlToString(str).Trim(); if (str != ""&&model.Title.Trim()!=""&&str.Length>5) { PrivateDb.UpdateTopic(model); return Json(model.Id); } return Json("内容或者标题不能太短哦"); }
public ActionResult CreateTopic(Topic model) { if (!Helper.HtmlHelper.IsEmpty(model.Content)&&model.Title.Length>=2) { var id = CheckValid(); var lastone = PrivateDb.LastOne((Topic t) => t.UserId == id); if (lastone!=null&&Helper.Helpers.DiffMinute(lastone.ActionTime, DateTime.Now) < 1) { return Json("ORZ,歇会儿再发起话题吧..."); } var topic = new Topic { ActionTime = DateTime.Now, UserId = id, Content = model.Content, Title = model.Title, UpDataTime = DateTime.Now, IsValid = true, UserName = GetUserNameById(id) }; PrivateDb.Add(topic); var one = PrivateDb.LastOne((Topic t) => t.UserId == id); return Json(one.Id); } return Json("内容或者标题不能太短哦"); }