Beispiel #1
0
        /// <summary>
        /// Fetches all content pages from database by specified id or language.
        /// </summary>
        /// <param name="id">Represents content page id.</param>
        /// <param name="languageID">The language ID.</param>
        /// <param name="sortColumn">The sort column.</param>
        /// <returns>Array of content pages.</returns>
        public static ContentPage[] FetchContentPages(object id, object languageID, eSortColumn sortColumn)
        {
            string cacheKey = String.Format("ContentPage_FetchContentPages_{0}_{1}_{2}", id, languageID, sortColumn);
            if (HttpContext.Current != null && HttpContext.Current.Cache[cacheKey] != null)
            {
                return HttpContext.Current.Cache[cacheKey] as ContentPage[];
            }

            var lPages = new List<ContentPage>(5);

            using (SqlConnection conn = Config.DB.Open())
            {
                SqlDataReader reader = (SqlDataReader) 
                    SqlHelper.GetDB().ExecuteReader(
                                            "FetchContentPages", id, languageID, sortColumn);

                while (reader.Read())
                {
                    var contentPage = new ContentPage();
                    contentPage.id = (int) reader["ID"];
                    contentPage.title = (string) reader["Title"];
                    contentPage.content = (string) reader["Content"];
                    contentPage.headerPosition = reader["HeaderPosition"] == DBNull.Value
                                                     ? null
                                                     : (int?) reader["HeaderPosition"];
                    contentPage.footerPosition = reader["FooterPosition"] == DBNull.Value
                                                     ? null
                                                     : (int?) reader["FooterPosition"];
                    contentPage.visibleFor = (eVisibility) (int) reader["VisibleFor"];
                    contentPage.url = reader["URL"] == DBNull.Value ? null : (string) reader["URL"];
                    contentPage.metaDescription = (string) reader["MetaDescription"];
                    contentPage.metaKeyword = (string) reader["MetaKeyword"];
                    contentPage.languageID = (int) reader["LanguageID"];
                    contentPage.urlRewrite = reader["UrlRewrite"] as string;

                    lPages.Add(contentPage);
                }
            }

            ContentPage[] pages = lPages.ToArray();
            if (HttpContext.Current != null)
            {
                //Global.AddCacheItem("ContentPage", cacheKey, pages);
                HttpContext.Current.Cache.Insert(cacheKey, pages, null, DateTime.Now.AddMinutes(30),
                                                 Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
            }

            return pages;
        }
Beispiel #2
0
        /// <summary>
        /// Creates the specified title.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="content">The content.</param>
        /// <param name="headerPosition">The header position.</param>
        /// <param name="footerPosition">The footer position.</param>
        /// <param name="visibleFor">The visible for.</param>
        /// <param name="url">The URL.</param>
        /// <param name="metaDescription">The meta description.</param>
        /// <param name="metaKeyword">The meta keyword.</param>
        /// <param name="languageID">The language ID.</param>
        /// <param name="urlRewrite">The URL rewrite.</param>
        /// <returns></returns>
        public static ContentPage Create(string title, string content, int? headerPosition,
                                         int? footerPosition, eVisibility visibleFor,
                                         string url, string metaDescription, string metaKeyword, int languageID,
                                         string urlRewrite)
        {
            var cp = new ContentPage
                         {
                             title = title,
                             content = content,
                             headerPosition = headerPosition,
                             footerPosition = footerPosition,
                             visibleFor = visibleFor,
                             url = url,
                             metaDescription = metaDescription,
                             metaKeyword = metaKeyword,
                             languageID = languageID,
                             urlRewrite = urlRewrite
                         };

            return cp;
        }