Ejemplo n.º 1
0
        public ActionResult Add(string title, string keywords, string description, string category, string imageURl, string contentStyle)
        {
            string result = "添加失败";

            if (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(category) && !string.IsNullOrEmpty(contentStyle))
            {
                SinglePage singlePage = new SinglePage();
                singlePage.EntityType = EnumEntityType.News.ToString();
                singlePage.Category = category;
                singlePage.Title = title;
                singlePage.Keywords = keywords;
                singlePage.Description = description;
                singlePage.ContentStyle = contentStyle;
                singlePage.ContentText = Witbird.SHTS.Common.Html.HtmlUtil.RemoveHTMLTags(singlePage.ContentStyle);
                singlePage.ImageUrl = imageURl;
                singlePage.IsActive = true;
                singlePage.ViewCount = 0;
                singlePage.InsertTime = DateTime.Now;
                if (singlePageManager.AddSinglePage(singlePage))
                {
                    result = "success";
                }
            }
            else
            {
                result = "必填项不能为空";
            }

            return Content(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 更新单页
 /// </summary>
 /// <param name="singlgePage">单页实体</param>
 public bool EditSinglePage(SinglePage singlgePage)
 {
     bool result = false;
     var conn = DBHelper.GetSqlConnection();
     try
     {
         conn.Open();
         if (singlgePage != null && !string.IsNullOrEmpty(singlgePage.EntityType))
         {
             result = SinglePageDao.UpdateSinglePage(singlgePage, conn);
         }
     }
     catch (Exception e)
     {
         LogService.Log("更新单页失败", e.ToString());
     }
     finally
     {
         conn.Close();
     }
     return result;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新单页
        /// </summary>
        public static bool UpdateSinglePage(SinglePage singlePage, SqlConnection conn)
        {
            object ParentId = DBNull.Value;
            object Category = DBNull.Value;
            object Title = DBNull.Value;
            object Keywords = DBNull.Value;
            object Description = DBNull.Value;
            object ContentStyle = DBNull.Value;
            object ContentText = DBNull.Value;
            object ImageUrl = DBNull.Value;
            object Link = DBNull.Value;
            object ViewCount = DBNull.Value;

            #region 转化DBNull
            if (null != singlePage.ParentId && 0 != singlePage.ParentId)
            {
                ParentId = singlePage.ParentId;
            }
            if (!string.IsNullOrEmpty(singlePage.Category))
            {
                Category = singlePage.Category;
            }
            if (!string.IsNullOrEmpty(singlePage.Title))
            {
                Title = singlePage.Title;
            }
            if (!string.IsNullOrEmpty(singlePage.Keywords))
            {
                Keywords = singlePage.Keywords;
            }
            if (!string.IsNullOrEmpty(singlePage.Description))
            {
                Description = singlePage.Description;
            }
            if (!string.IsNullOrEmpty(singlePage.ContentStyle))
            {
                ContentStyle = singlePage.ContentStyle;
            }
            if (!string.IsNullOrEmpty(singlePage.ContentText))
            {
                ContentText = singlePage.ContentText;
            }
            if (!string.IsNullOrEmpty(singlePage.ImageUrl))
            {
                ImageUrl = singlePage.ImageUrl;
            }
            if (!string.IsNullOrEmpty(singlePage.Link))
            {
                Link = singlePage.Link;
            }
            if (null != singlePage.ViewCount && 0 != singlePage.ViewCount)
            {
                ViewCount = singlePage.ViewCount;
            }
            #endregion

            SqlParameter[] sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@Id", singlePage.Id),
                new SqlParameter("@ParentId", ParentId),
                new SqlParameter("@EntityType", singlePage.EntityType),
                new SqlParameter("@Category", Category),
                new SqlParameter("@Title", Title),
                new SqlParameter("@Keywords", Keywords),
                new SqlParameter("@Description", Description),
                new SqlParameter("@ContentStyle", ContentStyle),
                new SqlParameter("@ContentText", ContentText),
                new SqlParameter("@ImageUrl", ImageUrl),
                new SqlParameter("@Link", Link),
                new SqlParameter("@ViewCount", ViewCount)
            };
            return DBHelper.SetDataToDB(conn, sp_SinglePageUpdate, sqlParameters);
        }