public override bool DeleteItem(ItemDefinition item, CallContext context)
        {
            var record = new AuditRecord {
                Event = "Deleted"
            };

            PopulateDefaultFields(item, record);

            record.EventData.Deleted = new Deleted();

            EventDataHelper.StoreRecord(record);

            return(true);
        }
        public override bool CreateItem(ID itemId, string itemName, ID templateId, ItemDefinition parent, DateTime created, CallContext context)
        {
            var item = GetItemDefinition(itemId, context);

            var record = new AuditRecord {
                Event = "Created"
            };

            PopulateDefaultFields(item, record);

            record.EventData.Created = new Created();

            EventDataHelper.StoreRecord(record);

            return(true);
        }
        public override bool RemoveVersion(ItemDefinition item, VersionUri version, CallContext context)
        {
            var record = new AuditRecord {
                Event = "VersionRemoved"
            };

            PopulateDefaultFields(item, record);

            record.EventData.VersionRemoved = new VersionRemoved {
                Version = version.Version.Number
            };

            EventDataHelper.StoreRecord(record);

            return(true);
        }
        public override bool MoveItem(ItemDefinition item, ItemDefinition destination, CallContext context)
        {
            var record = new AuditRecord {
                Event = "Moved"
            };

            PopulateDefaultFields(item, record);

            record.EventData.Moved = new Moved
            {
                DestinationPath = Database.GetDatabase("master").Items.GetItem(destination.ID).Paths.ContentPath
            };

            EventDataHelper.StoreRecord(record);

            return(true);
        }
        public override int AddVersion(ItemDefinition item, VersionUri baseVersion, CallContext context)
        {
            var baseVersionResult = baseVersion.Version.Number + 1;

            var record = new AuditRecord {
                Event = "VersionAdded"
            };

            PopulateDefaultFields(item, record);

            record.EventData.VersionAdded = new VersionAdded {
                Version = baseVersionResult
            };

            EventDataHelper.StoreRecord(record);

            return(baseVersion.Version.Number);
        }
        public override bool CopyItem(ItemDefinition item, ItemDefinition destination, string copyName, ID copyId, CallContext context)
        {
            var record = new AuditRecord {
                Event = "Copied"
            };

            PopulateDefaultFields(item, record);

            record.EventData.Copied = new Copied
            {
                ItemPath     = Database.GetDatabase("master").Items.GetItem(item.ID).Paths.ContentPath,
                ItemIdCopy   = destination.ID.ToString(),
                ItemNameCopy = destination.Name,
                ItemPathCopy = Database.GetDatabase("master").Items.GetItem(destination.ID).Paths.ContentPath
            };

            EventDataHelper.StoreRecord(record);

            return(true);
        }
        public override bool SaveItem(ItemDefinition item, ItemChanges changes, CallContext context)
        {
            var record = new AuditRecord {
                Event = "Saved"
            };

            PopulateDefaultFields(item, record);

            record.EventData.Saved = new Saved
            {
                Fields     = EventDataHelper.StoreFieldChanges(changes),
                Properties = EventDataHelper.StorePropertyChanges(changes)
            };

            // careful; if default fields are filtered out, this will skip an event from being saved altogether
            if (record.EventData.Saved.Fields.Count != 0 || record.EventData.Saved.Properties.Count != 0)
            {
                EventDataHelper.StoreRecord(record);
            }

            return(true);
        }