Beispiel #1
0
        async Task DoDelete(Entity entity, DeleteBehaviour behaviour)
        {
            // Raise deleting event
            if (!IsSet(behaviour, DeleteBehaviour.BypassDeleting))
            {
                var deletingArgs = new System.ComponentModel.CancelEventArgs();
                await Entity.Services.RaiseOnDeleting(entity, deletingArgs);

                if (deletingArgs.Cancel)
                {
                    Cache.Remove(entity);
                    return;
                }
            }

            if (SoftDeleteAttribute.IsEnabled(entity.GetType()) && !SoftDeleteAttribute.Context.ShouldByPassSoftDelete())
            {
                SoftDeleteAttribute.MarkDeleted(entity);
                await GetProvider(entity).Save(entity);
            }
            else
            {
                await GetProvider(entity).Delete(entity);
            }
        }
Beispiel #2
0
 IEntity HandleSoftDelete(Property[] fields, object[] values, IEntity entity)
 {
     if (ParticipatesInHierarchy)
     {
         var index = Array.FindIndex(fields, (x) => (x.Name == $"{ObjectType.TableName}__SoftDeleted"));
         if ((bool)values[index])
         {
             SoftDeleteAttribute.MarkDeleted((Entity)entity);
         }
     }
     else
     if ((bool)values[1])
     {
         SoftDeleteAttribute.MarkDeleted((Entity)entity);
     }
     return(entity);
 }