Beispiel #1
0
        /// <summary>
        /// Remove the specified entity.
        /// </summary>
        /// <param name="entity">Entity.</param>
        /// <typeparam name="TEntity">The entity type.</typeparam>
        public void Remove <TEntity>(TEntity entity) where TEntity : class, IEntity
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            persister.Delete(entity, entity.GetIdentity()?.Value);
        }
Beispiel #2
0
        public void DeletedItem_IsThrownInTrash()
        {
            var th = CreateTrashHandler();

            th.UseNavigationMode = true;

            DeleteInterceptor interceptor = new DeleteInterceptor(persister, th);

            interceptor.Start();

            persister.Delete(item);

            item.Parent.ShouldBeOfType <TrashContainerItem>();
        }
Beispiel #3
0
        public void RemoveLocation(int id)
        {
            var location = persister.Get <MagicLocation>(id);

            if (location != null)
            {
                persister.Delete(location);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Remove the specified entity.
        /// </summary>
        /// <param name="entity">Entity.</param>
        public void Remove(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            persister.Delete(entity, entity.GetIdentity()?.Value);
        }
 private void DeleteTranslations(ContentItem item)
 {
     foreach (ContentItem translatedItem in gateway.FindTranslations(item))
     {
         if (translatedItem != item)
         {
             persister.Delete(translatedItem);
         }
     }
 }
Beispiel #6
0
        /// <summary>Delete items lying in trash for longer than the specified interval.</summary>
        public void PurgeOldItems()
        {
            TrashContainerItem trash = GetTrashContainer(false);

            if (trash == null)
            {
                return;
            }
            if (trash.PurgeInterval == TrashPurgeInterval.Never)
            {
                return;
            }

            DateTime            tresholdDate = Utility.CurrentTime().AddDays(-(int)trash.PurgeInterval);
            IList <ContentItem> expiredItems = null;

            if (UseNavigationMode)
            {
                expiredItems = trash.Children
                               .Where(i => i[DeletedDate] != null)
                               .Where(i => ((DateTime)i[DeletedDate]) < tresholdDate)
                               .ToList();
            }
            else
            {
                expiredItems = finder.Where.Parent.Eq(trash)
                               .And.Detail(TrashHandler.DeletedDate).Le(tresholdDate)
                               .Select();
            }

            try
            {
                security.ScopeEnabled = false;
                foreach (var item in expiredItems)
                {
                    persister.Delete(item);
                }
            }
            finally
            {
                security.ScopeEnabled = true;
            }
        }
Beispiel #7
0
        public override NameValueCollection HandleRequest(NameValueCollection request)
        {
            ContentItem item = navigator.Navigate(request["item"]);

            if (item == null)
            {
                throw new N2Exception("Couln't find any item with the id: " + request[PathData.ItemQueryKey]);
            }
            persister.Delete(item);
            return(new NameValueCollection());
        }
Beispiel #8
0
 public virtual void Delete(ContentItem item)
 {
     try
     {
         security.ScopeEnabled = false;
         persister.Delete(item);
     }
     finally
     {
         security.ScopeEnabled = true;
     }
 }
Beispiel #9
0
        public virtual void Delete(ContentItem item)
        {
            using (security.Disable())
            {
                security.ScopeEnabled = false;
                persister.Delete(item);

                if (UserDeleted != null)
                {
                    UserDeleted(this, new ItemEventArgs(item));
                }
            }
        }
Beispiel #10
0
 public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus)
 {
     using (var tx = persister.Repository.BeginTransaction())
     {
         var result = new MigrationResult(this);;
         foreach (var redirect in persister.Repository.Find(new Parameter("class", "Redirect")).Where(p => p.Parent is Models.Pages.LanguageRoot))
         {
             persister.Delete(redirect);
             result.UpdatedItems++;
         }
         tx.Commit();
         return(result);
     }
 }
Beispiel #11
0
        public void RemoveTemplate(string templateKey)
        {
            TemplateContainer templates = container.GetBelowRoot();

            if (templates == null)
            {
                return;
            }

            ContentItem template = templates.GetChild(templateKey);

            if (template == null)
            {
                return;
            }

            persister.Delete(template);
        }
Beispiel #12
0
        public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus)
        {
            var parts  = persister.Repository.Find(new Parameter("class", "Top")).ToList();
            var result = new MigrationResult(this);;

            using (var tx = persister.Repository.BeginTransaction())
            {
                foreach (var part in parts.Where(p => p.State != ContentState.Deleted).Where(p => p.Parent != null))
                {
                    part.Parent.StoreEmbeddedPart("Header", part);
                    persister.Save(part.Parent);
                    persister.Delete(part);
                    result.UpdatedItems++;
                }
                tx.Commit();
                return(result);
            }
        }
        protected override void OnObjectDeleted(ObjectEventArgs e)
        {
            try
            {
                if (!_persister.Delete(e.Object))
                {
                    throw new PersisterException();
                }
            }
            catch (PersisterException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new PersisterException(ex);
            }

            base.OnObjectDeleted(e);
        }
Beispiel #14
0
        public override void Delete(string sourceName, string messageID)
        {
            int id;

            if (int.TryParse(messageID, out id))
            {
                var item = persister.Get(id);
                if (item is IMessageSource)
                {
                    var ex = integrity.GetDeleteException(item);
                    if (ex != null)
                    {
                        throw ex;
                    }

                    if (!security.IsAuthorized(context.User, item, item.IsPublished() ? Security.Permission.Publish : Security.Permission.Write))
                    {
                        throw new UnauthorizedAccessException();
                    }

                    persister.Delete(item);
                }
            }
        }
Beispiel #15
0
 /// <summary>
 /// Deletes the specified item from the data-store.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="identity">The item's identity.</param>
 /// <typeparam name="T">The item type.</typeparam>
 public void Delete <T>(T item, object identity) where T : class
 => wrapped.Delete <T>(item, identity);