Beispiel #1
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;
        }