コード例 #1
0
        /// <summary>
        /// Deletes the entity with the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="fireEvents">if set to <c>true</c> fire events.</param>
        public virtual void Delete(TId id, bool fireEvents = true)
        {
            DeletingEntityEventArgs args = null;

            if (fireEvents)
            {
                var existing = Get(id);
                args = new DeletingEntityEventArgs
                {
                    Entity = existing
                };

                Fluidity.OnDeletingEntity(args);

                if (args.Cancel)
                {
                    return;
                }
            }

            DeleteImpl(id);

            if (fireEvents)
            {
                Fluidity.OnDeletedEntity(args);
            }
        }
コード例 #2
0
        public void Delete(object id, bool fireEvents = true)
        {
            DeletingEntityEventArgs args = null;

            if (fireEvents)
            {
                var existing = Get(id);
                args = new DeletingEntityEventArgs
                {
                    Entity = existing
                };

                Fluidity.OnDeletingEntity(args);

                if (args.Cancel)
                {
                    return;
                }
            }

            var query = new Sql(_collection.DeletedProperty != null
                ? $"UPDATE {_collection.EntityType.GetTableName()} SET {_collection.DeletedProperty.GetColumnName()} = 1 WHERE {_collection.IdProperty.GetColumnName()} = @0"
                : $"DELETE FROM {_collection.EntityType.GetTableName()} WHERE {_collection.IdProperty.GetColumnName()} = @0",
                                id);

            Db.Execute(query);

            if (fireEvents)
            {
                Fluidity.OnDeletedEntity(args);
            }
        }
コード例 #3
0
ファイル: Fluidity.cs プロジェクト: xrisdoc/umbraco-fluidity
 public static void OnDeletingEntity(DeletingEntityEventArgs args)
 {
     DeletingEntity?.Invoke(null, args);
 }