/// <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); }
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>(); }
public void RemoveLocation(int id) { var location = persister.Get <MagicLocation>(id); if (location != null) { persister.Delete(location); } }
/// <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); } } }
/// <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; } }
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()); }
public virtual void Delete(ContentItem item) { try { security.ScopeEnabled = false; persister.Delete(item); } finally { security.ScopeEnabled = true; } }
public virtual void Delete(ContentItem item) { using (security.Disable()) { security.ScopeEnabled = false; persister.Delete(item); if (UserDeleted != null) { UserDeleted(this, new ItemEventArgs(item)); } } }
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); } }
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); }
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); }
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); } } }
/// <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);