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", LimitedToStores = true }; 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"); fromDb.LimitedToStores.ShouldEqual(true); }
/// <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); }
public static Topic ToEntity(this TopicModel model, Topic destination) { return Mapper.Map(model, destination); }
private 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); } else { model.SelectedStoreIds = new int[0]; } } }
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); } }
protected 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 role if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0) _storeMappingService.InsertStoreMapping(topic, store.Id); } else { //removed role var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id); if (storeMappingToDelete != null) _storeMappingService.DeleteStoreMapping(storeMappingToDelete); } } }