protected override void PersistUpdatedItem(IDictionaryItem entity)
        {
            entity.UpdatingEntity();

            foreach (var translation in entity.Translations)
            {
                translation.Value = translation.Value.ToValidXmlString();
            }

            var dto = DictionaryItemFactory.BuildDto(entity);

            Database.Update(dto);

            foreach (var translation in entity.Translations)
            {
                var textDto = DictionaryTranslationFactory.BuildDto(translation, entity.Key);
                if (translation.HasIdentity)
                {
                    Database.Update(textDto);
                }
                else
                {
                    translation.Id  = Convert.ToInt32(Database.Insert(textDto));
                    translation.Key = entity.Key;
                }
            }

            entity.ResetDirtyProperties();

            //Clear the cache entries that exist by uniqueid/item key
            IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, string>(entity.ItemKey));
            IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, Guid>(entity.Key));
        }
Esempio n. 2
0
        /// <inheritdoc />
        protected override void PersistUpdatedItem(IConsent entity)
        {
            ((EntityBase)entity).UpdatingEntity();

            var dto = ConsentFactory.BuildDto(entity);

            Database.Update(dto);
            entity.ResetDirtyProperties();

            IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IConsent>(entity.Id));
        }
        protected override void PersistDeletedItem(IDictionaryItem entity)
        {
            RecursiveDelete(entity.Key);

            Database.Delete <LanguageTextDto>("WHERE UniqueId = @Id", new { Id = entity.Key });
            Database.Delete <DictionaryDto>("WHERE id = @Id", new { Id = entity.Key });

            //Clear the cache entries that exist by uniqueid/item key
            IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, string>(entity.ItemKey));
            IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, Guid>(entity.Key));

            entity.DeleteDate = DateTime.Now;
        }
        private void RecursiveDelete(Guid parentId)
        {
            var list = Database.Fetch <DictionaryDto>("WHERE parent = @ParentId", new { ParentId = parentId });

            foreach (var dto in list)
            {
                RecursiveDelete(dto.UniqueId);

                Database.Delete <LanguageTextDto>("WHERE UniqueId = @Id", new { Id = dto.UniqueId });
                Database.Delete <DictionaryDto>("WHERE id = @Id", new { Id = dto.UniqueId });

                //Clear the cache entries that exist by uniqueid/item key
                IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, string>(dto.Key));
                IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, Guid>(dto.UniqueId));
            }
        }