Пример #1
0
        public ActionResult Create([Bind(Include = "IsAvailable,Name,ImgPath,Introduction,Content,Source,Author,CategoryID")] Info info, string ImgPathToDelete = "")
        {
            int    successCount = 0, notExistCount = 0;
            string msg = "";

            CommonUtil.RemoveFiles(ImgPathToDelete, out successCount, out notExistCount, out msg);
            info.ID        = IdentityCreator.NextIdentity;
            info.AddBy     = cuser.UserID;
            info.AddByName = cuser.LoginName;
            info.AddDate   = DateTime.Now;
            info.IsDel     = false;
            if (string.IsNullOrEmpty(Request["Introduction"]))
            {
                info.Introduction = info.Content.ToNoHtml().ToMaxString(200);
            }
            infoService.Add(info);
            if (infoService.SaveChanges(out msg) > 0)
            {
                return(Json(new AjaxResult()
                {
                    success = true, msg = insertSuccess, url = Url.Action("index", "info", "admin"), moremsg = msg
                }));
            }
            else
            {
                return(Json(new AjaxResult()
                {
                    success = false, msg = insertFailure, moremsg = msg
                }));
            }
        }