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); } }
public void Can_save_and_load_topic() { var topic = new Topic { SystemName = "SystemName 1", IncludeInSitemap = true, IsPasswordProtected = true, 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"); }
/// <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); }
/// <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); }
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 = "******", 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); }
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; }
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); } } }
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); } } }
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); } }
public static Topic ToEntity(this TopicModel model, Topic destination) { return Mapper.Map(model, destination); }
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); } } }
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); } } }
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) }); } }
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) }); } }
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; }