Exemple #1
0
        [ValidateInput(false)]//防止危险字符提交
        public string PostData()
        {
            try
            {
                string id        = Request["contentId"];
                string title     = Request["title"];
                string author    = Request["author"];
                string text      = Request["text"];
                int    type      = Convert.ToInt32(Request["type"]);
                int    label     = Convert.ToInt32(Request["label"]);
                string imagepath = Request["imagepaths"];
                string describe  = Tool.Tool.ParseTags(text);
                describe = GetStrNum(describe);

                int contentId = 0;
                int.TryParse(id, out contentId);

                ContentModel model = new ContentModel()
                {
                    Title     = title,
                    LabelId   = label,
                    Author    = author,
                    typeId    = type,
                    ImagePath = imagepath,
                    Text      = text
                };
                UserBLL bll = new UserBLL();
                if (contentId == 0)
                {
                    model.Describe   = describe;
                    model.CommentNum = 0;
                    model.CreateTime = DateTime.Now;
                    int res = bll.AddContent(model);
                    if (res > 0)
                    {
                        return("success:" + res.ToString());
                    }
                }
                else
                {
                    model.Id = contentId;
                    int res = bll.UpdateContent(model);
                    if (res > 0)
                    {
                        return("success:" + res.ToString());
                    }
                }
                return("failure:保存失败");
            }
            catch (Exception ex)
            {
                Log.WriteFile(ex);
                return("failure:" + ex.Message);
            }
        }