コード例 #1
0
        public News SaveInfo()
        {
            News news = this.NewsService.GetNewsById(NewsId);
            if (news != null)
            {
                news.LanguageId = int.Parse(this.ddlLanguage.SelectedItem.Value);
                news.Title = txtTitle.Text;
                news.Short = txtShort.Text;
                news.Full = txtFull.Value;
                news.Published = cbPublished.Checked;
                news.AllowComments = cbAllowComments.Checked;
                news.CreatedOn = DateTime.UtcNow;

                this.NewsService.UpdateNews(news);
            }
            else
            {
                news = new News()
                {
                    LanguageId = int.Parse(this.ddlLanguage.SelectedItem.Value),
                    Title = txtTitle.Text,
                    Short = txtShort.Text,
                    Full = txtFull.Value,
                    Published = cbPublished.Checked,
                    AllowComments = cbAllowComments.Checked,
                    CreatedOn = DateTime.UtcNow
                };
                this.NewsService.InsertNews(news);
            }
            return news;
        }
コード例 #2
0
ファイル: SEOHelper.cs プロジェクト: robbytarigan/ToyHouse
 /// <summary>
 /// Gets news URL
 /// </summary>
 /// <param name="news">News item</param>
 /// <returns>News URL</returns>
 public static string GetNewsUrl(News news)
 {
     if (news == null)
         throw new ArgumentNullException("news");
     string seName = GetSEName(news.Title);
     string url2 = SEOHelper.EnableUrlRewriting ? IoC.Resolve<ISettingManager>().GetSettingValue("SEO.News.UrlRewriteFormat") : "{0}News.aspx?NewsId={1}";
     string url = string.Format(url2, CommonHelper.GetStoreLocation(), news.NewsId, seName);
     return url.ToLowerInvariant();
 }
コード例 #3
0
ファイル: NewsService.cs プロジェクト: robbytarigan/ToyHouse
        /// <summary>
        /// Updates the news item
        /// </summary>
        /// <param name="news">News item</param>
        public void UpdateNews(News news)
        {
            if (news == null)
                throw new ArgumentNullException("news");

            news.Title = CommonHelper.EnsureNotNull(news.Title);
            news.Title = CommonHelper.EnsureMaximumLength(news.Title, 1000);
            news.Short = CommonHelper.EnsureNotNull(news.Short);
            news.Short = CommonHelper.EnsureMaximumLength(news.Short, 4000);
            news.Full = CommonHelper.EnsureNotNull(news.Full);

            if (!_context.IsAttached(news))
                _context.News.Attach(news);

            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(NEWS_PATTERN_KEY);
            }
        }
コード例 #4
0
ファイル: SEOHelper.cs プロジェクト: juliakolesen/voobrazi.by
 /// <summary>
 /// Gets news URL
 /// </summary>
 /// <param name="news">News item</param>
 /// <returns>News URL</returns>
 public static string GetNewsURL(News news)
 {
     if (news == null)
         throw new ArgumentNullException("news"); 
     string seName = GetSEName(news.Title);
     string url = string.Format(SettingManager.GetSettingValue("SEO.News.UrlRewriteFormat"), CommonHelper.GetStoreLocation(), news.NewsID, seName);
     return url;
 }