本文整理汇总了C#中Nop.Core.Domain.News.NewsItem.GetSeName方法的典型用法代码示例。如果您正苦于以下问题:C# NewsItem.GetSeName方法的具体用法?C# NewsItem.GetSeName怎么用?C# NewsItem.GetSeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nop.Core.Domain.News.NewsItem
的用法示例。
在下文中一共展示了NewsItem.GetSeName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapNewsItemModel
private NewsItemModel MapNewsItemModel(NewsItem newsItem)
{
if (newsItem == null)
throw new ArgumentNullException("newsItem");
return new NewsItemModel
{
Id = newsItem.Id,
SeName = newsItem.GetSeName(newsItem.LanguageId, ensureTwoPublishedLanguages: false),
Title = newsItem.Title,
Short = newsItem.Short,
CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.CreatedOnUtc, DateTimeKind.Utc)
};
}
示例2: PrepareNewsItemModel
protected virtual void PrepareNewsItemModel(NewsItemModel model, NewsItem newsItem, bool prepareComments)
{
if (newsItem == null)
throw new ArgumentNullException("newsItem");
if (model == null)
throw new ArgumentNullException("model");
model.Id = newsItem.Id;
model.MetaTitle = newsItem.MetaTitle;
model.MetaDescription = newsItem.MetaDescription;
model.MetaKeywords = newsItem.MetaKeywords;
model.SeName = newsItem.GetSeName(newsItem.LanguageId, ensureTwoPublishedLanguages: false);
model.Title = newsItem.Title;
model.Short = newsItem.Short;
model.Full = newsItem.Full;
model.AllowComments = newsItem.AllowComments;
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.CreatedOnUtc, DateTimeKind.Utc);
model.NumberOfComments = newsItem.CommentCount;
model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnNewsCommentPage;
if (prepareComments)
{
var newsComments = newsItem.NewsComments.OrderBy(pr => pr.CreatedOnUtc);
foreach (var nc in newsComments)
{
var commentModel = new NewsCommentModel()
{
Id = nc.Id,
CustomerId = nc.CustomerId,
CustomerName = nc.Customer.FormatUserName(),
CommentTitle = nc.CommentTitle,
CommentText = nc.CommentText,
CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc),
AllowViewingProfiles = _customerSettings.AllowViewingProfiles && nc.Customer != null && !nc.Customer.IsGuest(),
};
if (_customerSettings.AllowCustomersToUploadAvatars)
{
commentModel.CustomerAvatarUrl = _pictureService.GetPictureUrl(
nc.Customer.GetAttribute<int>(SystemCustomerAttributeNames.AvatarPictureId),
_mediaSettings.AvatarPictureSize,
_customerSettings.DefaultAvatarEnabled,
defaultPictureType:PictureType.Avatar);
}
model.Comments.Add(commentModel);
}
}
}
示例3: PrepareNewsItemModel
protected void PrepareNewsItemModel(NewsItemModel model, NewsItem newsItem, bool prepareComments)
{
if (newsItem == null)
throw new ArgumentNullException("newsItem");
if (model == null)
throw new ArgumentNullException("model");
model.Id = newsItem.Id;
model.SeName = newsItem.GetSeName();
model.Title = newsItem.Title;
model.Short = newsItem.Short;
model.Full = newsItem.Full;
model.AllowComments = newsItem.AllowComments;
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.CreatedOnUtc, DateTimeKind.Utc);
model.NumberOfComments = newsItem.NewsComments.Count;
if (prepareComments)
{
var newsComments = newsItem.NewsComments.Where(pr => pr.IsApproved).OrderBy(pr => pr.CreatedOnUtc);
foreach (var nc in newsComments)
{
var commentModel = new NewsCommentModel()
{
Id = nc.Id,
CustomerId = nc.CustomerId,
CustomerName = nc.Customer.FormatUserName(),
CommentTitle = nc.CommentTitle,
CommentText = nc.CommentText,
CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc),
AllowViewingProfiles = _customerSettings.AllowViewingProfiles && nc.Customer != null && !nc.Customer.IsGuest(),
};
if (_customerSettings.AllowCustomersToUploadAvatars)
{
var customer = nc.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);
}
}
}
示例4: PrepareNewsItemModel
protected virtual void PrepareNewsItemModel(NewsItemModel model, NewsItem newsItem, bool prepareComments, bool preparePictureModel = true, int? newsThumbPictureSize = null)
{
if (newsItem == null)
throw new ArgumentNullException("newsItem");
if (model == null)
throw new ArgumentNullException("model");
model.Id = newsItem.Id;
model.MetaTitle = newsItem.MetaTitle;
model.MetaDescription = newsItem.MetaDescription;
model.MetaKeywords = newsItem.MetaKeywords;
model.SeName = newsItem.GetSeName(newsItem.LanguageId, ensureTwoPublishedLanguages: false);
model.Title = newsItem.Title;
model.Short = newsItem.Short;
model.Full = newsItem.Full;
model.AllowComments = newsItem.AllowComments;
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.CreatedOnUtc, DateTimeKind.Utc);
model.NumberOfComments = newsItem.CommentCount;
model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnNewsCommentPage;
if(preparePictureModel)
{
#region Prepare news picture
//If a size has been set in the view, we use it in priority
int pictureSize = newsThumbPictureSize.HasValue ? newsThumbPictureSize.Value : _mediaSettings.NewsThumbPictureSize;
//prepare picture model
var defaultNewsPictureCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_DEFAULTPICTURE_MODEL_KEY, newsItem.Id, pictureSize, true, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured(), _storeContext.CurrentStore.Id);
model.DefaultPictureModel = _cacheManager.Get(defaultNewsPictureCacheKey, () =>
{
var picture = _pictureService.GetPicturesByNewsId(newsItem.Id, 1).FirstOrDefault();
var pictureModel = new PictureModel
{
ImageUrl = _pictureService.GetPictureUrl(picture, pictureSize),
FullSizeImageUrl = _pictureService.GetPictureUrl(picture),
Title = string.Format(_localizationService.GetResource("Media.News.ImageLinkTitleFormat"), model.Title),
AlternateText = string.Format(_localizationService.GetResource("Media.News.ImageAlternateTextFormat"), model.Title)
};
return pictureModel;
});
#endregion
}
if (prepareComments)
{
var newsComments = newsItem.NewsComments.OrderBy(pr => pr.CreatedOnUtc);
foreach (var nc in newsComments)
{
var commentModel = new NewsCommentModel
{
Id = nc.Id,
CustomerId = nc.CustomerId,
CustomerName = nc.Customer.FormatUserName(),
CommentTitle = nc.CommentTitle,
CommentText = nc.CommentText,
CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc),
AllowViewingProfiles = _customerSettings.AllowViewingProfiles && nc.Customer != null && !nc.Customer.IsGuest(),
};
if (_customerSettings.AllowCustomersToUploadAvatars)
{
commentModel.CustomerAvatarUrl = _pictureService.GetPictureUrl(
nc.Customer.GetAttribute<int>(SystemCustomerAttributeNames.AvatarPictureId),
_mediaSettings.AvatarPictureSize,
_customerSettings.DefaultAvatarEnabled,
defaultPictureType:PictureType.Avatar);
}
model.Comments.Add(commentModel);
}
}
}