本文整理汇总了C#中Nop.Core.Domain.Blogs.BlogPost类的典型用法代码示例。如果您正苦于以下问题:C# BlogPost类的具体用法?C# BlogPost怎么用?C# BlogPost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlogPost类属于Nop.Core.Domain.Blogs命名空间,在下文中一共展示了BlogPost类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_save_and_load_blogPost
public void Can_save_and_load_blogPost()
{
var blogPost = new BlogPost
{
Title = "Title 1",
Body = "Body 1",
AllowComments = true,
Tags = "Tags 1",
CreatedOnUtc = new DateTime(2010, 01, 01),
Language = new Language()
{
Name = "English",
LanguageCulture = "en-Us",
}
};
var fromDb = SaveAndLoadEntity(blogPost);
fromDb.ShouldNotBeNull();
fromDb.Title.ShouldEqual("Title 1");
fromDb.Body.ShouldEqual("Body 1");
fromDb.AllowComments.ShouldEqual(true);
fromDb.Tags.ShouldEqual("Tags 1");
fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));
fromDb.Language.ShouldNotBeNull();
fromDb.Language.Name.ShouldEqual("English");
}
示例2: Can_save_and_load_blogPost_with_blogComments
public void Can_save_and_load_blogPost_with_blogComments()
{
var blogPost = new BlogPost
{
Title = "Title 1",
Body = "Body 1",
AllowComments = true,
CreatedOnUtc = new DateTime(2010, 01, 01),
Language = new Language
{
Name = "English",
LanguageCulture = "en-Us",
}
};
blogPost.BlogComments.Add
(
new BlogComment
{
CreatedOnUtc = new DateTime(2010, 01, 03),
Customer = GetTestCustomer()
}
);
var fromDb = SaveAndLoadEntity(blogPost);
fromDb.ShouldNotBeNull();
fromDb.BlogComments.ShouldNotBeNull();
(fromDb.BlogComments.Count == 1).ShouldBeTrue();
}
示例3: DeleteBlogPost
/// <summary>
/// Deletes a blog post
/// </summary>
/// <param name="blogPost">Blog post</param>
public virtual void DeleteBlogPost(BlogPost blogPost)
{
if (blogPost == null)
throw new ArgumentNullException("blogPost");
_blogPostRepository.Delete(blogPost);
//event notification
_eventPublisher.EntityDeleted(blogPost);
}
示例4: DeleteBlogPost
/// <summary>
/// Deletes a blog post
/// </summary>
/// <param name="blogPost">Blog post</param>
public virtual void DeleteBlogPost(BlogPost blogPost)
{
if (blogPost == null)
throw new ArgumentNullException("blogPost");
_blogPostRepository.Delete(blogPost);
_cacheManager.RemoveByPattern(BLOGPOST_PATTERN_KEY);
//event notification
_eventPublisher.EntityDeleted(blogPost);
}
示例5: Can_parse_tags
public void Can_parse_tags()
{
var blogPost = new BlogPost
{
Tags = "tag1, tag2, tag 3 4, "
};
var tags = blogPost.ParseTags();
tags.Length.ShouldEqual(3);
tags[0].ShouldEqual("tag1");
tags[1].ShouldEqual("tag2");
tags[2].ShouldEqual("tag 3 4");
}
示例6: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(BlogPostModel model, BlogPost blogPost, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableStores = _storeService
.GetAllStores()
.Select(s => s.ToModel())
.ToList();
if (!excludeProperties)
{
if (blogPost != null)
{
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(blogPost);
}
}
}
示例7: Can_save_and_load_blogPost
public void Can_save_and_load_blogPost()
{
var blogPost = new BlogPost
{
Title = "Title 1",
Body = "Body 1",
BodyOverview = "BodyOverview 1",
AllowComments = true,
CommentCount = 1,
Tags = "Tags 1",
StartDateUtc = new DateTime(2010, 01, 01),
EndDateUtc = new DateTime(2010, 01, 02),
CreatedOnUtc = new DateTime(2010, 01, 03),
MetaTitle = "MetaTitle 1",
MetaDescription = "MetaDescription 1",
MetaKeywords = "MetaKeywords 1",
LimitedToStores = true,
Language = new Language
{
Name = "English",
LanguageCulture = "en-Us",
}
};
var fromDb = SaveAndLoadEntity(blogPost);
fromDb.ShouldNotBeNull();
fromDb.Title.ShouldEqual("Title 1");
fromDb.Body.ShouldEqual("Body 1");
fromDb.BodyOverview.ShouldEqual("BodyOverview 1");
fromDb.AllowComments.ShouldEqual(true);
fromDb.CommentCount.ShouldEqual(1);
fromDb.Tags.ShouldEqual("Tags 1");
fromDb.StartDateUtc.ShouldEqual(new DateTime(2010, 01, 01));
fromDb.EndDateUtc.ShouldEqual(new DateTime(2010, 01, 02));
fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 03));
fromDb.MetaTitle.ShouldEqual("MetaTitle 1");
fromDb.MetaDescription.ShouldEqual("MetaDescription 1");
fromDb.MetaKeywords.ShouldEqual("MetaKeywords 1");
fromDb.LimitedToStores.ShouldEqual(true);
fromDb.Language.ShouldNotBeNull();
fromDb.Language.Name.ShouldEqual("English");
}
示例8: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(BlogPostModel model, BlogPost blogPost, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
if (!excludeProperties && blogPost != null)
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(blogPost).ToList();
var allStores = _storeService.GetAllStores();
foreach (var store in allStores)
{
model.AvailableStores.Add(new SelectListItem
{
Text = store.Name,
Value = store.Id.ToString(),
Selected = model.SelectedStoreIds.Contains(store.Id)
});
}
}
示例9: SaveStoreMappings
protected void SaveStoreMappings(BlogPost blogPost, BlogPostModel model)
{
var existingStoreMappings = _storeMappingService.GetStoreMappings(blogPost);
var allStores = _storeService.GetAllStores();
foreach (var store in allStores)
{
if (model.SelectedStoreIds != null && model.SelectedStoreIds.Contains(store.Id))
{
//new role
if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0)
_storeMappingService.InsertStoreMapping(blogPost, store.Id);
}
else
{
//removed role
var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id);
if (storeMappingToDelete != null)
_storeMappingService.DeleteStoreMapping(storeMappingToDelete);
}
}
}
示例10: ToEntity
public static BlogPost ToEntity(this BlogPostModel model, BlogPost destination)
{
return Mapper.Map(model, destination);
}
示例11: PrepareBlogPostModel
protected void PrepareBlogPostModel(BlogPostModel model, BlogPost blogPost, bool prepareComments)
{
if (blogPost == null)
throw new ArgumentNullException("blogPost");
if (model == null)
throw new ArgumentNullException("model");
model.Id = blogPost.Id;
model.SeName = blogPost.GetSeName(blogPost.LanguageId, ensureTwoPublishedLanguages: false);
model.Title = blogPost.Title;
model.Body = blogPost.Body;
model.AllowComments = blogPost.AllowComments;
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(blogPost.CreatedOnUtc, DateTimeKind.Utc);
model.Tags = blogPost.ParseTags().ToList();
model.NumberOfComments = blogPost.ApprovedCommentCount;
model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnBlogCommentPage;
if (prepareComments)
{
var blogComments = blogPost.BlogComments.Where(pr => pr.IsApproved).OrderBy(pr => pr.CreatedOnUtc);
foreach (var bc in blogComments)
{
var commentModel = new BlogCommentModel()
{
Id = bc.Id,
CustomerId = bc.CustomerId,
CustomerName = bc.Customer.FormatUserName(),
CommentText = bc.CommentText,
CreatedOn = _dateTimeHelper.ConvertToUserTime(bc.CreatedOnUtc, DateTimeKind.Utc),
AllowViewingProfiles = _customerSettings.AllowViewingProfiles && bc.Customer != null && !bc.Customer.IsGuest(),
};
if (_customerSettings.AllowCustomersToUploadAvatars)
{
commentModel.CustomerAvatarUrl = _pictureService.GetPictureUrl(
bc.Customer.GetAttribute<int>(SystemCustomerAttributeNames.AvatarPictureId),
_mediaSettings.AvatarPictureSize,
_customerSettings.DefaultAvatarEnabled,
defaultPictureType: PictureType.Avatar);
}
model.Comments.Add(commentModel);
}
}
}
示例12: PrepareBlogPostModel
private void PrepareBlogPostModel(BlogPostModel model, BlogPost blogPost, bool prepareComments)
{
if (blogPost == null)
throw new ArgumentNullException("blogPost");
if (model == null)
throw new ArgumentNullException("model");
model.Id = blogPost.Id;
model.SeName = blogPost.GetSeName();
model.Title = blogPost.Title;
model.Body = blogPost.Body;
model.AllowComments = blogPost.AllowComments;
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(blogPost.CreatedOnUtc, DateTimeKind.Utc);
model.Tags = blogPost.ParseTags().ToList();
model.NumberOfComments = blogPost.BlogComments.Count;
if (prepareComments)
{
var blogComments = blogPost.BlogComments.Where(pr => pr.IsApproved).OrderBy(pr => pr.CreatedOnUtc);
foreach (var bc in blogComments)
{
var commentModel = new BlogCommentModel()
{
Id = bc.Id,
CustomerId = bc.CustomerId,
CustomerName = bc.Customer.FormatUserName(),
CommentText = bc.CommentText,
CreatedOn = _dateTimeHelper.ConvertToUserTime(bc.CreatedOnUtc, DateTimeKind.Utc),
AllowViewingProfiles = _customerSettings.AllowViewingProfiles && bc.Customer != null && !bc.Customer.IsGuest(),
};
if (_customerSettings.AllowCustomersToUploadAvatars)
{
var customer = bc.Customer;
string avatarUrl = _pictureService.GetPictureUrl(customer.GetAttribute<int>(SystemCustomerAttributeNames.AvatarPictureId), _mediaSettings.AvatarPictureSize, false);
if (String.IsNullOrEmpty(avatarUrl) && _customerSettings.DefaultAvatarEnabled)
avatarUrl = _pictureService.GetDefaultPictureUrl(_mediaSettings.AvatarPictureSize, PictureType.Avatar);
commentModel.CustomerAvatarUrl = avatarUrl;
}
model.Comments.Add(commentModel);
}
}
}
示例13: UpdateCommentTotals
/// <summary>
/// Update blog post comment totals
/// </summary>
/// <param name="blogPost">Blog post</param>
public virtual void UpdateCommentTotals(BlogPost blogPost)
{
if (blogPost == null)
throw new ArgumentNullException("blogPost");
int approvedCommentCount = 0;
int notApprovedCommentCount = 0;
var blogComments = blogPost.BlogComments;
foreach (var bc in blogComments)
{
if (bc.IsApproved)
approvedCommentCount++;
else
notApprovedCommentCount++;
}
blogPost.ApprovedCommentCount = approvedCommentCount;
blogPost.NotApprovedCommentCount = notApprovedCommentCount;
UpdateBlogPost(blogPost);
}
示例14: PrepareBlogPostModel
protected virtual void PrepareBlogPostModel(BlogPostModel model, BlogPost blogPost, bool prepareComments)
{
if (blogPost == null)
throw new ArgumentNullException("blogPost");
if (model == null)
throw new ArgumentNullException("model");
model.Id = blogPost.Id;
model.MetaTitle = blogPost.MetaTitle;
model.MetaDescription = blogPost.MetaDescription;
model.MetaKeywords = blogPost.MetaKeywords;
model.SeName = blogPost.GetSeName(blogPost.LanguageId, ensureTwoPublishedLanguages: false);
model.Title = blogPost.Title;
model.Body = blogPost.Body;
model.BodyOverview = blogPost.BodyOverview;
model.AllowComments = blogPost.AllowComments;
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(blogPost.StartDateUtc ?? blogPost.CreatedOnUtc, DateTimeKind.Utc);
model.Tags = blogPost.ParseTags().ToList();
model.NumberOfComments = blogPost.CommentCount;
model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnBlogCommentPage;
if (prepareComments)
{
var blogComments = _blogService.GetBlogCommentsByBlogPostId(blogPost.Id);
foreach (var bc in blogComments)
{
var customer = EngineContext.Current.Resolve<ICustomerService>().GetCustomerById(bc.CustomerId);
var commentModel = new BlogCommentModel
{
Id = bc.Id,
CustomerId = bc.CustomerId,
CustomerName = customer.FormatUserName(),
CommentText = bc.CommentText,
CreatedOn = _dateTimeHelper.ConvertToUserTime(bc.CreatedOnUtc, DateTimeKind.Utc),
AllowViewingProfiles = _customerSettings.AllowViewingProfiles && customer != null && !customer.IsGuest(),
};
if (_customerSettings.AllowCustomersToUploadAvatars)
{
commentModel.CustomerAvatarUrl = _pictureService.GetPictureUrl(
customer.GetAttribute<int>(SystemCustomerAttributeNames.AvatarPictureId),
_mediaSettings.AvatarPictureSize,
_customerSettings.DefaultAvatarEnabled,
defaultPictureType: PictureType.Avatar);
}
model.Comments.Add(commentModel);
}
}
}