public BlogPost SaveInfo()
        {
            BlogPost blogPost = this.BlogService.GetBlogPostById(this.BlogPostId);
            if (blogPost != null)
            {
                blogPost.LanguageId = int.Parse(this.ddlLanguage.SelectedItem.Value);
                blogPost.BlogPostTitle = txtBlogPostTitle.Text;
                blogPost.BlogPostBody = txtBlogPostBody.Value;
                blogPost.BlogPostAllowComments = cbBlogPostAllowComments.Checked;
                blogPost.Tags = txtTags.Text.Trim();

                this.BlogService.UpdateBlogPost(blogPost);
            }
            else
            {
                blogPost = new BlogPost()
                {
                    LanguageId = int.Parse(this.ddlLanguage.SelectedItem.Value),
                    BlogPostTitle = txtBlogPostTitle.Text,
                    BlogPostBody = txtBlogPostBody.Value,
                    BlogPostAllowComments = cbBlogPostAllowComments.Checked,
                    Tags = txtTags.Text.Trim(),
                    CreatedById = NopContext.Current.User.CustomerId,
                    CreatedOn = DateTime.UtcNow
                };
                this.BlogService.InsertBlogPost(blogPost);
            }
            return blogPost;
        }
        private static BlogPost DBMapping(DBBlogPost dbItem)
        {
            if (dbItem == null)
                return null;

            BlogPost item = new BlogPost();
            item.BlogPostID = dbItem.BlogPostID;
            item.LanguageID = dbItem.LanguageID;
            item.BlogPostTitle = dbItem.BlogPostTitle;
            item.BlogPostBody = dbItem.BlogPostBody;
            item.BlogPostAllowComments = dbItem.BlogPostAllowComments;
            item.CreatedByID = dbItem.CreatedByID;
            item.CreatedOn = dbItem.CreatedOn;

            return item;
        }
Beispiel #3
0
 /// <summary>
 /// Gets blog post URL
 /// </summary>
 /// <param name="blogPost">Blog post</param>
 /// <returns>Blog post URL</returns>
 public static string GetBlogPostUrl(BlogPost blogPost)
 {
     if (blogPost == null)
         throw new ArgumentNullException("blogPost");
     string seName = GetSEName(blogPost.BlogPostTitle);
     string url2 = SEOHelper.EnableUrlRewriting ? IoC.Resolve<ISettingManager>().GetSettingValue("SEO.Blog.UrlRewriteFormat") : "{0}BlogPost.aspx?BlogPostID={1}";
     string url = string.Format(url2, CommonHelper.GetStoreLocation(), blogPost.BlogPostId, seName);
     return url.ToLowerInvariant();
 }
Beispiel #4
0
        protected string RenderBlogTags(BlogPost blogPost)
        {
            StringBuilder sb = new StringBuilder();
            var tags = blogPost.ParsedTags;

            if (tags.Length > 0)
            {
                sb.Append(GetLocaleResourceString("Blog.Tags"));
                sb.Append(" ");

                for (int i = 0; i < tags.Length; i++)
                {
                    string tag = tags[i].Trim();

                    string url = SEOHelper.GetBlogUrlForTag(tag);
                    sb.Append(string.Format("<a href=\"{0}\">{1}</a>", url, Server.HtmlEncode(tag)));
                    if (i != tags.Length - 1)
                    {
                        sb.Append(", ");
                    }
                }
            }

            return sb.ToString();
        }
Beispiel #5
0
        /// <summary>
        /// Updates the blog post
        /// </summary>
        /// <param name="blogPost">Blog post</param>
        public void UpdateBlogPost(BlogPost blogPost)
        {
            if (blogPost == null)
                throw new ArgumentNullException("blogPost");

            blogPost.BlogPostTitle = CommonHelper.EnsureNotNull(blogPost.BlogPostTitle);
            blogPost.BlogPostTitle = CommonHelper.EnsureMaximumLength(blogPost.BlogPostTitle, 200);
            blogPost.BlogPostBody = CommonHelper.EnsureNotNull(blogPost.BlogPostBody);
            blogPost.Tags = CommonHelper.EnsureNotNull(blogPost.Tags);
            blogPost.Tags = CommonHelper.EnsureMaximumLength(blogPost.Tags, 4000);

            if (!_context.IsAttached(blogPost))
                _context.BlogPosts.Attach(blogPost);

            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(BLOGPOST_PATTERN_KEY);
            }
        }
Beispiel #6
0
 /// <summary>
 /// Gets blog post URL
 /// </summary>
 /// <param name="blogPost">Blog post</param>
 /// <returns>Blog post URL</returns>
 public static string GetBlogPostURL(BlogPost blogPost)
 {
     if (blogPost == null)
         throw new ArgumentNullException("blogPost"); 
     string seName = GetSEName(blogPost.BlogPostTitle);
     string url = string.Format(SettingManager.GetSettingValue("SEO.Blog.UrlRewriteFormat"), CommonHelper.GetStoreLocation(), blogPost.BlogPostID, seName);
     return url;
 }