本文整理汇总了C#中Nop.Core.Domain.Topics.Topic类的典型用法代码示例。如果您正苦于以下问题:C# Topic类的具体用法?C# Topic怎么用?C# Topic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Topic类属于Nop.Core.Domain.Topics命名空间,在下文中一共展示了Topic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateLocales
protected void UpdateLocales(Topic topic, TopicModel model)
{
foreach (var localized in model.Locales)
{
_localizedEntityService.SaveLocalizedValue(topic,
x => x.Title,
localized.Title,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(topic,
x => x.Body,
localized.Body,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(topic,
x => x.MetaKeywords,
localized.MetaKeywords,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(topic,
x => x.MetaDescription,
localized.MetaDescription,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(topic,
x => x.MetaTitle,
localized.MetaTitle,
localized.LanguageId);
//search engine name
var seName = topic.ValidateSeName(localized.SeName, localized.Title, false);
_urlRecordService.SaveSlug(topic, seName, localized.LanguageId);
}
}
示例2: Can_save_and_load_topic
public void Can_save_and_load_topic()
{
var topic = new Topic
{
SystemName = "SystemName 1",
IncludeInSitemap = true,
IsPasswordProtected = true,
Password = "password",
Title = "Title 1",
Body = "Body 1",
MetaKeywords = "Meta keywords",
MetaDescription = "Meta description",
MetaTitle = "Meta title",
};
var fromDb = SaveAndLoadEntity(topic);
fromDb.ShouldNotBeNull();
fromDb.SystemName.ShouldEqual("SystemName 1");
fromDb.IncludeInSitemap.ShouldEqual(true);
fromDb.IsPasswordProtected.ShouldEqual(true);
fromDb.Password.ShouldEqual("password");
fromDb.Title.ShouldEqual("Title 1");
fromDb.Body.ShouldEqual("Body 1");
fromDb.MetaKeywords.ShouldEqual("Meta keywords");
fromDb.MetaDescription.ShouldEqual("Meta description");
fromDb.MetaTitle.ShouldEqual("Meta title");
}
示例3: DeleteTopic
/// <summary>
/// Deletes a topic
/// </summary>
/// <param name="topic">Topic</param>
public virtual void DeleteTopic(Topic topic)
{
if (topic == null)
throw new ArgumentNullException("topic");
_topicRepository.Delete(topic);
//event notification
_eventPublisher.EntityDeleted(topic);
}
示例4: DeleteTopic
/// <summary>
/// Deletes a topic
/// </summary>
/// <param name="topic">Topic</param>
public virtual void DeleteTopic(Topic topic)
{
if (topic == null)
throw new ArgumentNullException("topic");
_topicRepository.Delete(topic);
//cache
_cacheManager.RemoveByPattern(TOPICS_PATTERN_KEY);
//event notification
_eventPublisher.EntityDeleted(topic);
}
示例5: Can_save_and_load_topic
public void Can_save_and_load_topic()
{
var topic = new Topic
{
SystemName = "SystemName 1",
IncludeInSitemap = true,
IncludeInTopMenu = true,
IncludeInFooterColumn1 = true,
IncludeInFooterColumn2 = true,
IncludeInFooterColumn3 = true,
DisplayOrder = 1,
AccessibleWhenStoreClosed = true,
IsPasswordProtected = true,
Password = "password",
Title = "Title 1",
Body = "Body 1",
Published = true,
TopicTemplateId = 1,
MetaKeywords = "Meta keywords",
MetaDescription = "Meta description",
MetaTitle = "Meta title",
SubjectToAcl = true,
LimitedToStores = true
};
var fromDb = SaveAndLoadEntity(topic);
fromDb.ShouldNotBeNull();
fromDb.SystemName.ShouldEqual("SystemName 1");
fromDb.IncludeInSitemap.ShouldEqual(true);
fromDb.IncludeInTopMenu.ShouldEqual(true);
fromDb.IncludeInFooterColumn1.ShouldEqual(true);
fromDb.IncludeInFooterColumn2.ShouldEqual(true);
fromDb.IncludeInFooterColumn3.ShouldEqual(true);
fromDb.DisplayOrder.ShouldEqual(1);
fromDb.AccessibleWhenStoreClosed.ShouldEqual(true);
fromDb.IsPasswordProtected.ShouldEqual(true);
fromDb.Password.ShouldEqual("password");
fromDb.Title.ShouldEqual("Title 1");
fromDb.Body.ShouldEqual("Body 1");
fromDb.Published.ShouldEqual(true);
fromDb.TopicTemplateId.ShouldEqual(1);
fromDb.MetaKeywords.ShouldEqual("Meta keywords");
fromDb.MetaDescription.ShouldEqual("Meta description");
fromDb.MetaTitle.ShouldEqual("Meta title");
fromDb.SubjectToAcl.ShouldEqual(true);
fromDb.LimitedToStores.ShouldEqual(true);
}
示例6: PrepareTopicModel
protected virtual TopicModel PrepareTopicModel(Topic topic)
{
if (topic == null)
throw new ArgumentNullException("topic");
var model = new TopicModel()
{
Id = topic.Id,
SystemName = topic.SystemName,
IncludeInSitemap = topic.IncludeInSitemap,
IsPasswordProtected = topic.IsPasswordProtected,
Title = topic.IsPasswordProtected ? "" : topic.GetLocalized(x => x.Title),
Body = topic.IsPasswordProtected ? "" : topic.GetLocalized(x => x.Body),
MetaKeywords = topic.GetLocalized(x => x.MetaKeywords),
MetaDescription = topic.GetLocalized(x => x.MetaDescription),
MetaTitle = topic.GetLocalized(x => x.MetaTitle),
SeName = topic.GetSeName(),
};
return model;
}
示例7: SaveStoreMappings
protected virtual void SaveStoreMappings(Topic topic, TopicModel model)
{
var existingStoreMappings = _storeMappingService.GetStoreMappings(topic);
var allStores = _storeService.GetAllStores();
foreach (var store in allStores)
{
if (model.SelectedStoreIds != null && model.SelectedStoreIds.Contains(store.Id))
{
//new store
if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0)
_storeMappingService.InsertStoreMapping(topic, store.Id);
}
else
{
//remove store
var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id);
if (storeMappingToDelete != null)
_storeMappingService.DeleteStoreMapping(storeMappingToDelete);
}
}
}
示例8: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(TopicModel model, Topic topic, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableStores = _storeService
.GetAllStores()
.Select(s => s.ToModel())
.ToList();
if (!excludeProperties)
{
if (topic != null)
{
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(topic);
}
}
}
示例9: UpdateLocales
protected void UpdateLocales(Topic topic, TopicModel model)
{
foreach (var localized in model.Locales)
{
_localizedEntityService.SaveLocalizedValue(topic,
x => x.Title,
localized.Title,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(topic,
x => x.Body,
localized.Body,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(topic,
x => x.MetaKeywords,
localized.MetaKeywords,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(topic,
x => x.MetaDescription,
localized.MetaDescription,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(topic,
x => x.MetaTitle,
localized.MetaTitle,
localized.LanguageId);
}
}
示例10: ToEntity
public static Topic ToEntity(this TopicModel model, Topic destination)
{
return Mapper.Map(model, destination);
}
示例11: SaveTopicAcl
protected virtual void SaveTopicAcl(Topic topic, TopicModel model)
{
var existingAclRecords = _aclService.GetAclRecords(topic);
var allCustomerRoles = _customerService.GetAllCustomerRoles(true);
foreach (var customerRole in allCustomerRoles)
{
if (model.SelectedCustomerRoleIds != null && model.SelectedCustomerRoleIds.Contains(customerRole.Id))
{
//new role
if (existingAclRecords.Count(acl => acl.CustomerRoleId == customerRole.Id) == 0)
_aclService.InsertAclRecord(topic, customerRole.Id);
}
else
{
//remove role
var aclRecordToDelete = existingAclRecords.FirstOrDefault(acl => acl.CustomerRoleId == customerRole.Id);
if (aclRecordToDelete != null)
_aclService.DeleteAclRecord(aclRecordToDelete);
}
}
}
示例12: PrepareAclModel
protected virtual void PrepareAclModel(TopicModel model, Topic topic, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableCustomerRoles = _customerService
.GetAllCustomerRoles(true)
.Select(cr => cr.ToModel())
.ToList();
if (!excludeProperties)
{
if (topic != null)
{
model.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccess(topic);
}
}
}
示例13: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(TopicModel model, Topic topic, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
if (!excludeProperties && topic != null)
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(topic).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)
});
}
}
示例14: PrepareAclModel
protected virtual void PrepareAclModel(TopicModel model, Topic topic, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
if (!excludeProperties && topic != null)
model.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccess(topic).ToList();
var allRoles = _customerService.GetAllCustomerRoles(true);
foreach (var role in allRoles)
{
model.AvailableCustomerRoles.Add(new SelectListItem
{
Text = role.Name,
Value = role.Id.ToString(),
Selected = model.SelectedCustomerRoleIds.Contains(role.Id)
});
}
}
示例15: UpdateLocales
protected virtual List<LocalizedProperty> UpdateLocales(Topic topic, TopicModel model)
{
List<LocalizedProperty> localized = new List<LocalizedProperty>();
foreach (var local in model.Locales)
{
var seName = topic.ValidateSeName(local.SeName, local.Title, false);
_urlRecordService.SaveSlug(topic, seName, local.LanguageId);
if (!(String.IsNullOrEmpty(seName)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "SeName",
LocaleValue = seName
});
if (!(String.IsNullOrEmpty(local.Body)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "Body",
LocaleValue = local.Body
});
if (!(String.IsNullOrEmpty(local.MetaDescription)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "MetaDescription",
LocaleValue = local.MetaDescription
});
if (!(String.IsNullOrEmpty(local.MetaKeywords)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "MetaKeywords",
LocaleValue = local.MetaKeywords
});
if (!(String.IsNullOrEmpty(local.MetaTitle)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "MetaTitle",
LocaleValue = local.MetaTitle
});
if (!(String.IsNullOrEmpty(local.Title)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "Title",
LocaleValue = local.Title
});
}
return localized;
}