public void DeleteArticleGroup(ArticleGroup articleGroup) { if (articleGroup == null) throw new ArgumentNullException("articleGroup"); articleGroup.Deleted = true; UpdateArticleGroup(articleGroup); //set a ParentArticleGroup property of the children to 0 var subarticleGroups = GetAllGroupsByParentGroupId(articleGroup.Id); foreach (var subarticleGroup in subarticleGroups) { subarticleGroup.ParentGroupId = 0; UpdateArticleGroup(subarticleGroup); } }
public void InsertArticleGroup(ArticleGroup articleGroup) { if (articleGroup == null) throw new ArgumentNullException("articleGroup"); _articleGroupRepository.Insert(articleGroup); //cache _cacheManager.RemoveByPattern(GROUPS_PATTERN_KEY); _cacheManager.RemoveByPattern(ARTICLEGROUPS_PATTERN_KEY); //event notification _eventPublisher.EntityInserted(articleGroup); }
public void UpdateArticleGroup(ArticleGroup articleGroup) { if (articleGroup == null) throw new ArgumentNullException("articleGroup"); //validate articleGroup hierarchy var parentArticleGroup = GetArticleGroupById(articleGroup.ParentGroupId); while (parentArticleGroup != null) { if (articleGroup.Id == parentArticleGroup.Id) { articleGroup.ParentGroupId = 0; break; } parentArticleGroup = GetArticleGroupById(parentArticleGroup.ParentGroupId); } _articleGroupRepository.Update(articleGroup); //cache _cacheManager.RemoveByPattern(GROUPS_PATTERN_KEY); _cacheManager.RemoveByPattern(ARTICLEGROUPS_PATTERN_KEY); //event notification _eventPublisher.EntityUpdated(articleGroup); }
private void PrepareStoresMappingModel(ArticleGroupModel model, ArticleGroup articleGroup, bool excludeProperties) { if (model == null) throw new ArgumentNullException("model"); model.AvailableStores = _storeService .GetAllStores() .Select(s => s.ToModel()) .ToList(); if (!excludeProperties) { if (articleGroup != null) { model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(articleGroup); } else { model.SelectedStoreIds = new int[0]; } } }
protected void UpdatePictureSeoNames(ArticleGroup articleGroup) { var picture = _pictureService.GetPictureById(articleGroup.PictureId); if (picture != null) _pictureService.SetSeoFilename(picture.Id, _pictureService.GetPictureSeName(articleGroup.Name)); }
protected void UpdateLocales(ArticleGroup articleGroup, ArticleGroupModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(articleGroup, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(articleGroup, x => x.Description, localized.Description, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(articleGroup, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(articleGroup, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(articleGroup, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(articleGroup, x => x.SeName, localized.SeName, localized.LanguageId); } }
protected void SaveStoreMappings(ArticleGroup articleGroup, ArticleGroupModel model) { var existingStoreMappings = _storeMappingService.GetStoreMappings(articleGroup); 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(articleGroup, store.Id); } else { //removed role var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id); if (storeMappingToDelete != null) _storeMappingService.DeleteStoreMapping(storeMappingToDelete); } } }
public static ArticleGroup ToEntity(this ArticleGroupModel model, ArticleGroup destination) { return Mapper.Map(model, destination); }