Beispiel #1
0
        public ActionResult AddOrEdit()
        {
            ReturnValue retValue = new ReturnValue();

            Article entity = new Article();
            entity.ID = CodeNote.Common.ConvertWrap.ToInt(Request["articleid"]);
            entity.Subject = Request["subject"];
            entity.Body = CodeNote.Common.StringFilter.ClearHtml(Request["body"],true);
            entity.CategoryID = Request["category"];
            entity.Tag = Request["artitag"];
            entity.CreateID = CurUser.ID;
            entity.CreateDate = DateTime.Now;
            entity.ModDate = entity.CreateDate;

            retValue = ArtMg.AddOrEdit(entity);

            if (retValue.IsExists)
            {//添加标签或修改标签
                TagInfoManager tagMg = new TagInfoManager();
                Models.Constans.TagType tagType = Constans.TagType.UserTag;
                if (CurUser != null && CurUser.Type == (int)Constans.UserType.Administrators)
                {
                    tagType = Constans.TagType.SysTag;
                }
                tagMg.AddTag(entity.Tag, (int)tagType);
                CodeNote.Luc.ArtilceLuc artLuc = new Luc.ArtilceLuc();
                artLuc.ModifyIndex(retValue.Get<VwArticle>("vw"));
            }

            return View("Result", new ReturnMessage(Request, "提示消息", retValue));
        }
Beispiel #2
0
        public ReturnValue AddOrEdit(Article entity)
        {
            ReturnValue retValue = new ReturnValue();
            if (string.IsNullOrEmpty(entity.Subject))
            {
                retValue.IsExists = false;
                retValue.Message = "标题不能为空";
                return retValue;
            }
            if (string.IsNullOrEmpty(entity.Body))
            {
                retValue.IsExists = false;
                retValue.Message = "正文不能为空";
                return retValue;
            }
            VwArticle old = null;
            using (ArticleDal dal = new ArticleDal())
            {

                if (entity.ID > 0)
                {
                    old = dal.GetVw(entity.ID);
                }
                if (old == null)
                {
                    if (dal.Add(entity))
                    {
                        retValue.IsExists = true;
                        retValue.Message = "保存成功";
                        old = dal.GetVw(entity.ID);
                    }
                    else
                    {
                        retValue.IsExists = false;
                        retValue.Message = "保存失败";
                    }
                }
                else //修改
                {
                    if (dal.Modify(entity))
                    {
                        retValue.IsExists = true;
                        retValue.Message = "修改成功";
                        old = dal.GetVw(entity.ID);
                    }
                    else
                    {
                        retValue.IsExists = false;
                        retValue.Message = "修改失败";
                    }
                }
            }

            if (retValue.IsExists)
            {
                //TODO: 修改Html
                HtmlManager htmMg = new HtmlManager();
                htmMg.CreateHtml(old);
            }
            retValue.PutValue("vw", old);

            return retValue;
        }