/// <summary> /// Inserts a celebrity tag /// </summary> /// <param name="celebrityTag">Celebrity tag</param> public virtual void InsertCelebrityTag(CelebrityTag celebrityTag) { if (celebrityTag == null) { throw new ArgumentNullException(nameof(celebrityTag)); } _celebrityTagRepository.Insert(celebrityTag); //event notification _eventPublisher.EntityInserted(celebrityTag); }
protected virtual void UpdateLocales(CelebrityTag celebrityTag, CelebrityTagModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(celebrityTag, x => x.Name, localized.Name, localized.LanguageId); var seName = _urlRecordService.ValidateSeName(celebrityTag, string.Empty, localized.Name, false); _urlRecordService.SaveSlug(celebrityTag, seName, localized.LanguageId); } }
/// <summary> /// Updates the celebrity tag /// </summary> /// <param name="celebrityTag">Celebrity tag</param> public virtual void UpdateCelebrityTag(CelebrityTag celebrityTag) { if (celebrityTag == null) { throw new ArgumentNullException(nameof(celebrityTag)); } _celebrityTagRepository.Update(celebrityTag); var seName = _urlRecordService.ValidateSeName(celebrityTag, string.Empty, celebrityTag.Name, true); _urlRecordService.SaveSlug(celebrityTag, seName, 0); //event notification _eventPublisher.EntityUpdated(celebrityTag); }
/// <summary> /// Update celebrity tags /// </summary> /// <param name="celebrity">Celebrity for update</param> /// <param name="celebrityTags">Celebrity tags</param> public virtual void UpdateCelebrityTags(Celebrity celebrity, string[] celebrityTags) { if (celebrity == null) { throw new ArgumentNullException(nameof(celebrity)); } //celebrity tags var existingCelebrityTags = GetAllCelebrityTagsByCelebrityId(celebrity.Id); var celebrityTagsToRemove = new List <CelebrityTag>(); foreach (var existingCelebrityTag in existingCelebrityTags) { var found = false; foreach (var newCelebrityTag in celebrityTags) { if (!existingCelebrityTag.Name.Equals(newCelebrityTag, StringComparison.InvariantCultureIgnoreCase)) { continue; } found = true; break; } if (!found) { celebrityTagsToRemove.Add(existingCelebrityTag); } } foreach (var celebrityTag in celebrityTagsToRemove) { DeleteCelebrityCelebrityTagMapping(celebrity.Id, celebrityTag.Id); } foreach (var celebrityTagName in celebrityTags) { CelebrityTag celebrityTag; var celebrityTag2 = GetCelebrityTagByName(celebrityTagName); if (celebrityTag2 == null) { //add new celebrity tag celebrityTag = new CelebrityTag { Name = celebrityTagName }; InsertCelebrityTag(celebrityTag); } else { celebrityTag = celebrityTag2; } if (!CelebrityTagExists(celebrity, celebrityTag.Id)) { InsertCelebrityCelebrityTagMapping(new CelebrityCelebrityTagMapping { CelebrityTagId = celebrityTag.Id, CelebrityId = celebrity.Id }); } var seName = _urlRecordService.ValidateSeName(celebrityTag, string.Empty, celebrityTag.Name, true); _urlRecordService.SaveSlug(celebrityTag, seName, 0); } //cache _staticCacheManager.RemoveByPrefix(NopCatalogDefaults.CelebrityTagPrefixCacheKey); }