コード例 #1
0
 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)
     {
         LoveDb.UpdateTopic(model);
         return Json(model.Id);
     }
     return Json("内容或者标题不能太短哦");
 }
コード例 #2
0
        public ActionResult CreateTopic(Topic model)
        {
            if (!Helper.HtmlHelper.IsEmpty(model.Content)&&model.Title.Length>=2)
            {
                var id = CheckValid();
                var lastone = LoveDb.LastOne((Topic t) => t.UserId == id);
                if (lastone!=null&&Helper.Helpers.DiffMinute(lastone.ActionTime, DateTime.Now) < 30)
                {
                    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)
                };
                LoveDb.Add(topic);
                var one = LoveDb.LastOne((Topic t) => t.UserId == id);
                return Json(one.Id);

            }
            return Json("内容或者标题不能太短哦");
        }