当前位置: 首页>>代码示例>>C#>>正文


C# BlogPost类代码示例

本文整理汇总了C#中BlogPost的典型用法代码示例。如果您正苦于以下问题:C# BlogPost类的具体用法?C# BlogPost怎么用?C# BlogPost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BlogPost类属于命名空间,在下文中一共展示了BlogPost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        public ActionResult Create(BlogPost blogPost)
        {
            RavenSession.Store(blogPost);
              RavenSession.SaveChanges();

              return RedirectToAction("Index");
        }
开发者ID:haiku80,项目名称:raventest,代码行数:7,代码来源:BlogPostsController.cs

示例2: ConvertPost

        public static BlogPost ConvertPost(BloggerPostData post)
        {
            if (post == null)
            {
                throw new ArgumentNullException(nameof(post));
            }

            var author = new BlogAuthor
                             {
                                 ImageUrl = post.Author?.Image?.Url,
                                 Name = post.Author?.DisplayName,
                                 SourceId = post.Author?.Id,
                                 Url = post.Author?.Url
                             };

            // Properties set by BlogSyncServiceUpdatePostsHelper: BlavenId, UrlSlug
            var blogPost = new BlogPost
                               {
                                   BlogAuthor = author,
                                   Content = post.Content,
                                   Hash = GetBlogPostHash(post),
                                   PublishedAt = post.Published,
                                   SourceId = post.Id,
                                   SourceUrl = post.Url,
                                   BlogPostTags =
                                       post.Labels?.Select(x => new BlogPostTag(x)).ToList() ?? new List<BlogPostTag>(),
                                   Title = post.Title,
                                   UpdatedAt = post.Updated
                               };
            return blogPost;
        }
开发者ID:sebnilsson,项目名称:Blaven,代码行数:31,代码来源:BloggerDataConverter.cs

示例3: Initialize

		/// <summary>
		/// Retrieving all blog posts here, so this only has to be called once.
		/// </summary>
		internal ICollection<BlogPost> Initialize(bool redirect)
		{
			var blog = Retriever.GetBlog(_blogService);
			var blogPosts = _blogPostService.Get(blog, VersionOptions.Published);
			_allBlogPosts = new List<BlogPost>();
			string redirects = string.Empty;
			foreach (var blogPostPart in blogPosts)
			{
				if (redirect) 
				{
					string currentSlug = GetUrl(blogPostPart);
					string redirectRule = "<location path=\"{0}\"><system.webServer><httpRedirect enabled=\"true\" destination=\"http://jan-v.nl/post/{0}\" httpResponseStatus=\"Permanent\" /></system.webServer></location>";
					redirects = redirects + string.Format(redirectRule, currentSlug);
				}
				else {

					var blogPost = new BlogPost();
					blogPost.Title = blogPostPart.Title;
					blogPost.Content = blogPostPart.Text;
					blogPost.PubDate = blogPostPart.PublishedUtc.Value;
					blogPost.LastModified = blogPostPart.PublishedUtc.Value;
					//blogPost.Categories = blogPostPart.;
					blogPost.Slug = GetUrl(blogPostPart);
					blogPost.Author = blogPostPart.Creator.UserName;
					blogPost.IsPublished = true;

					_allBlogPosts.Add(blogPost);
					Storage.Save(blogPost, string.Format("C:\\BlogPosts\\{0}.xml", blogPost.Slug));
				}
				
			}
			return _allBlogPosts;
		}
开发者ID:Jandev,项目名称:JanVNL.Migrate,代码行数:36,代码来源:GetBlogPost.cs

示例4: bindPostOne

        private void bindPostOne( IBlock listBlock, BlogPost post )
        {
            String status = string.Empty;
               // if (post.IsTop == 1) status = "<span class=\"lblTop\">[" + lang( "sticky" ) + "]</span>";
             //   if (post.IsPick == 1) status = status + "<span class=\"lblTop\">[" + lang( "picked" ) + "]</span>";

               // listBlock.Set( "blogpost.Status", status );
            listBlock.Set( "blogpost.Title", post.Title );
            listBlock.Set( "blogpost.Url", alink.ToAppData( post ) );
            listBlock.Set( "blogpost.Body", strUtil.ParseHtml( post.Content, 300 ) );
            listBlock.Set( "author", ctx.owner.obj.Name );
            listBlock.Set( "authroUrl", Link.ToMember( ctx.owner.obj ) );
            listBlock.Set( "blogpost.CreateTime", post.Created.ToShortTimeString() );
            listBlock.Set( "blogpost.CreateDate", post.Created.ToShortDateString() );
            listBlock.Set( "blogpost.Hits", post.Hits );
            listBlock.Set( "blogpost.ReplyCount", post.Replies );
            if (ctx.viewer.IsLogin && (ctx.viewer.Id == ctx.owner.Id))
            {
                listBlock.Set("EditUrlStyle", "");

            }
            else
            {
                listBlock.Set("EditUrlStyle", "display:none");

            }
            listBlock.Set("blogpost.EditUrl", to(new Admin.PostController().Edit, post.Id));
        }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:28,代码来源:CategoryController.cs

示例5: bindPostOne

        private void bindPostOne( IBlock listBlock, BlogPost post, BlogSetting s ) {

            String status = string.Empty;
            if (post.IsTop == 1) status = "<span class=\"lblTop\">[" + lang( "sticky" ) + "]</span>";
            if (post.IsPick == 1) status = status + "<span class=\"lblTop\">[" + lang( "picked" ) + "]</span>";
            if (post.AttachmentCount > 0) {
                status = status + string.Format( "<span><img src=\"{0}\"/></span>", strUtil.Join( sys.Path.Img, "attachment.gif" ) );
            }

            String postLink = alink.ToAppData( post );

            listBlock.Set( "blogpost.Status", status );
            listBlock.Set( "blogpost.Title", post.Title );
            listBlock.Set( "blogpost.Url", postLink );

            String body = s.ListMode == BlogListMode.Full ? post.Content : strUtil.ParseHtml( post.Content, s.ListAbstractLength );
            listBlock.Set( "blogpost.Body", body );
            listBlock.Set( "author", ctx.owner.obj.Name );
            listBlock.Set( "authroUrl", Link.ToMember( ctx.owner.obj ) );
            listBlock.Set( "blogpost.CreateTime", post.Created.ToShortTimeString() );
            listBlock.Set( "blogpost.CreateDate", post.Created.ToShortDateString() );
            listBlock.Set( "blogpost.Hits", post.Hits );

            String replies = post.Replies > 0 ?
                string.Format( "<a href=\"{0}\">{1}(<span class=\"blogItemReviews\">{2}</span>)</a>", postLink + "#comments", lang( "comment" ), post.Replies ) :
                string.Format( "<a href=\"{0}\">发表评论</a>", postLink + "#comments" );
            listBlock.Set( "blogpost.ReplyCount", replies );


            listBlock.Set( "blogpost.CategoryName", post.Category.Name );
            listBlock.Set( "blogpost.CategoryLink", to( new CategoryController().Show, post.Category.Id ) );

            String tags = post.Tag.List.Count > 0 ? "tag:" + post.Tag.HtmlString : "";
            listBlock.Set( "blogpost.TagList", tags );
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:35,代码来源:BlogController.cs

示例6: Index_GIVEN_BlogPostRepository_Has_1_BlogSummary_THEN_Sets_BlogSummaryViewModel_To_Have_Same_Values

        public void Index_GIVEN_BlogPostRepository_Has_1_BlogSummary_THEN_Sets_BlogSummaryViewModel_To_Have_Same_Values()
        {
            const string title = "Title";
            const string description = "Description";
            var url = new Uri("http://www.jumbleblocks.co.uk/noimage.jpg");
            var publishedDate = DateTime.Now;
            var author = new BlogUser { Forenames = "Authors", Surname = "Name" };

            var blogPosts = new BlogPost[]
            {
                new BlogPost(title, description, "full article", new ImageReference(1, url:url.AbsoluteUri), publishedDate, author)
            };

            var mockedBlogPostRepository = new Mock<IBlogPostRepository>();
            mockedBlogPostRepository.Setup(r => r.GetPosts(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<IEnumerable<string>>())).Returns(blogPosts);
            mockedBlogPostRepository.Setup(r => r.Count).Returns(blogPosts.Length);

            var controller = MockCreators.CreateBlogPostController(blogPostRepository: mockedBlogPostRepository.Object);

            var result = controller.Index() as ViewResult;

            var model = (FrontPageModel)result.Model;
            model.Summaries.First().Title.ShouldEqual(title);
            model.Summaries.First().Description.ShouldEqual(description);
            model.Summaries.First().ImageUrl.ShouldEqual(url);
            model.Summaries.First().PublishedDate.ShouldEqual(publishedDate);
            model.Summaries.First().AuthorsName.ShouldEqual(author.FullName);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:28,代码来源:BlogFrontPageTests.cs

示例7: getStatus

 private String getStatus( BlogPost post )
 {
     //if (pickedService.IsPicked( post )) return "<span class='red'>[" + lang( "recommend" ) + "]</span>&nbsp;";
     //return "";
     if (post.IsPick > 0) return "<span class='red'>[" + lang("recommend") + "]</span>&nbsp;";
     return "";
 }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:7,代码来源:MainController.cs

示例8: Post

 public async Task<IHttpActionResult> Post(BlogPost m)
 {
     if (!ModelState.IsValid)
         return BadRequest(ModelState);
     m.CreateTime = System.DateTimeOffset.Now;
     //TODO:获取当前用户
     m.UserId = "{B0FBB2AC-3174-4E5A-B772-98CF776BD4B9}";
     //添加博客
     m = db.BlogPost.Add(m);
     try
     {
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception("发布博客失败:" + ex.Message);
     }
      int postId =m.Id;
     //添加多个标签
     foreach (int tagId in m.BlogTagIds)
     {
         db.BlogPostTag.Add(
         new BlogPostTag
         {
             PostId = postId,
             BlogTagId = tagId,
             CreateTime = DateTime.Now,
             Deleted = false
         });
     }
     await db.SaveChangesAsync();
     return Created<BlogPost>(m);
 }
开发者ID:leloulight,项目名称:Magicodes.NET,代码行数:33,代码来源:BlogsPostODataController.cs

示例9: Ctor_WHEN_fullArticle_Is_Abc_THEN_Sets_FullArticle_Property_To_Abc

        public void Ctor_WHEN_fullArticle_Is_Abc_THEN_Sets_FullArticle_Property_To_Abc()
        {
            const string fullArticle = "ABC";

            var post = new BlogPost("a", "description", fullArticle, GetImageReference(), DateTime.Now, new BlogUser());
            post.FullArticle.ShouldEqual(fullArticle);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:7,代码来源:BlogPostTests.cs

示例10: ImageReference

        public void BlogPostController_Edit_GIVEN_BlogPostRepository_Contains_BlogPost_With_ID_1_WHEN_blogPostId_Is_1_THEN_Returns_ViewModel_For_BlogPost()
        {
            const int BlogPostId = 1;

            var imageReference = new ImageReference(1, "/noimage.jpg");
            var author = new BlogUser { Id = 1, Forenames = "Joe", Surname = "Blogs" };

            var blogPost = new BlogPost("Test", "This is the description", "Not much in this article", imageReference, DateTime.Now, author);
            blogPost.SetProperty("Id", BlogPostId);
            blogPost.UpdateSeries(new Series { Name = "Series A" });
            blogPost.UpdateTags(new Tag[] { new Tag { Text = "Tag 1" } });

            var mockedBlogPostRepository = new Mock<IBlogPostRepository>();
            mockedBlogPostRepository.Setup(r => r.Load(BlogPostId)).Returns(blogPost);

            var controller = MockCreators.CreateBlogPostController(blogPostRepository: mockedBlogPostRepository.Object);
            var result = controller.Edit(blogPost.Id.Value) as ViewResult;

            result.ShouldNotBeNull();
            result.Model.ShouldBeInstanceOfType(typeof(CreateEditModel));

            var model = (CreateEditModel)result.Model;

            model.BlogPostId.ShouldEqual(blogPost.Id);
            model.PublishedDate.ShouldEqual(blogPost.PublishedDate);
            model.Title.ShouldEqual(blogPost.Title);
            model.Description.ShouldEqual(blogPost.Description);
            model.FullArticle.ShouldEqual(blogPost.FullArticle);
            model.ImageId.ShouldEqual(blogPost.ImageReference.Id.Value);
            model.SeriesName.ShouldEqual(blogPost.Series.Name);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:31,代码来源:EditArticleTests.cs

示例11: Ctor_WHEN_author_has_value_THEN_Sets_Author_Property_To_That_Value

        public void Ctor_WHEN_author_has_value_THEN_Sets_Author_Property_To_That_Value()
        {
            var author = new BlogUser();

            var post = new BlogPost("a", "b", "c", GetImageReference(), DateTime.Now, author);
            post.Author.ShouldEqual(author);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:7,代码来源:BlogPostTests.cs

示例12: Ctor_WHEN_description_Is_Abc_THEN_Sets_Description_Property_To_Abc

        public void Ctor_WHEN_description_Is_Abc_THEN_Sets_Description_Property_To_Abc()
        {
            const string description = "ABC";

            var post = new BlogPost("a", description, "fullArticle", GetImageReference(), DateTime.Now, new BlogUser());
            post.Description.ShouldEqual(description);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:7,代码来源:BlogPostTests.cs

示例13: ImageReference

        public void BlogPostController_List_GIVEN_BlogPost_Has_1_Item_THEN_Returns_1_ArticleListingViewModel_With_Data_From_Post()
        {
            const int BlogPostId = 1;

            var imageReference = new ImageReference(1, "/noimage.jpg");
            var author = new BlogUser { Id = 1, Forenames = "Joe", Surname = "Blogs" };

            var blogPost = new BlogPost("Test", "This is the description", "Not much in this article", imageReference, DateTime.Now, author);
            blogPost.SetProperty("Id", BlogPostId);
            blogPost.UpdateSeries(new Series { Name = "Series A" });
            blogPost.UpdateTags(new Tag[] { new Tag { Text = "Tag 1" } });

            var mockedBlogPostRepository = new Mock<IBlogPostRepository>();

            mockedBlogPostRepository.Setup(r => r.LoadAll()).Returns(new BlogPost[] { blogPost });

            var controller = MockCreators.CreateBlogPostController(blogPostRepository: mockedBlogPostRepository.Object);
            var result = controller.List() as ViewResult;

            result.ShouldNotBeNull();
            result.Model.ShouldBeInstanceOfType(typeof(IEnumerable<BlogPostListingItemModel>));

            var viewModelForPost = ((IEnumerable<BlogPostListingItemModel>)result.Model).First();

            viewModelForPost.BlogPostId.ShouldEqual(blogPost.Id.Value);
            viewModelForPost.Title.ShouldEqual(blogPost.Title);
            viewModelForPost.PublishedDate.ShouldEqual(blogPost.PublishedDate);
            viewModelForPost.AuthorsName.ShouldEqual(blogPost.Author.FullName);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:29,代码来源:ListArticleTests.cs

示例14: RenderFlatTaxaAsLink

        public string RenderFlatTaxaAsLink(BlogPost post, string taxonomyFieldName)
        {
            var baseUrl = string.Empty;
              var currentProvider = SiteMapBase.GetCurrentProvider();

              if (currentProvider == null || currentProvider != null && currentProvider.CurrentNode == null) { return string.Empty; } else {
            var currentNode = currentProvider.CurrentNode as PageSiteNode;
            if (currentNode == null) { baseUrl = currentProvider.CurrentNode.Url; } else {
              var firstPageDataNode = RouteHelper.GetFirstPageDataNode(currentNode, true);
              if (!currentNode.IsGroupPage || !(firstPageDataNode.Url != currentProvider.CurrentNode.Url)) { baseUrl = currentProvider.CurrentNode.Url; } else {
            baseUrl = firstPageDataNode.Url;
              }
            }
              }

              var tagList = "";
              var tags = post.GetValue<TrackedList<Guid>>(taxonomyFieldName);

              if (tags != null && tags.Count() > 0) {
            tagList = " | ";
            var taxManager = TaxonomyManager.GetManager();
            foreach (var tag in tags) {
              var t = taxManager.GetTaxon<FlatTaxon>(tag);
              var url = string.Format("{0}/-in-{1}/{2}/{3}", VirtualPathUtility.ToAbsolute(baseUrl), t.Taxonomy.Name, t.Taxonomy.Name, t.UrlName);
              var link = string.Format("<a class='tag' href='{0}'><span>{1}</span></a>", url, t.Title).ToString();
              tagList += link;
            }
              }

              return tagList;
        }
开发者ID:sonofabit,项目名称:BlogListFilterByTag,代码行数:31,代码来源:ListView.ascx.cs

示例15: CreateMockedBlogPostRepository

        public static Mock<IBlogPostRepository> CreateMockedBlogPostRepository(bool shouldBlogPostRepositoryAlwayReturnPost = true, int blogPostCount = 20)
        {
            //TODO: may need to allow return of specific blog post if no match
            var blogPostList = new List<BlogPost>();

            for (int i = 0; i < blogPostCount; i++)
            {
                var blogPost = new BlogPost(i.ToString(), i.ToString(), i.ToString(), new ImageReference(1, "/noimage.jpg"), DateTime.Now, new BlogUser());
                blogPost.SetProperty(p => p.Id, i);
                blogPostList.Add(blogPost);
            }

            var mockedBlogPostRepository = new Mock<IBlogPostRepository>();

            mockedBlogPostRepository.Setup(r => r.Count).Returns(blogPostCount);
            mockedBlogPostRepository.Setup(r => r.LoadAll()).Returns(blogPostList);

            mockedBlogPostRepository.Setup(r => r.LoadFrom(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>()))
                .Returns<int, int, int, string>((year, month, day, title) => ReturnBlogPost(year, month, day, title, blogPostList, shouldBlogPostRepositoryAlwayReturnPost));

            mockedBlogPostRepository.Setup(r => r.GetPosts(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<IEnumerable<string>>()))
                .Returns<int, int, IEnumerable<string>>((skip, take, tags) => blogPostList.Skip(skip).Take(take));

            return mockedBlogPostRepository;
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:25,代码来源:MockCreators.cs


注:本文中的BlogPost类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。