protected virtual EntityAudit CreateAudit(DbContext context, DbEntityEntry entry, EntityAuditAction action)
        {
            var audit = new EntityAudit {
                Action         = action,
                AppDomain      = this.GetAppDomain(context, entry),
                UserName       = this.GetUserName(context, entry),
                IdentityType   = this.GetIdentitType(context, entry),
                EntityID       = this.GetEntityId(context, entry),
                EntityType     = entry.Entity.GetType().FullName,
                DateCreatedUtc = DateTime.UtcNow,
                Properties     = new List <EntityAuditProperty>()
            };

            return(audit);
        }
        public override void OnPreInsert(DbContext context, DbEntityEntry entry)
        {
            if (!this.ShouldAudit(entry))
            {
                return;
            }

            this.currentInsert = this.CreateAudit(context, entry, EntityAuditAction.Insert);
            entry
            .CurrentValues
            .PropertyNames
            .Select(entry.Property)
            .ToList()
            .ForEach(x =>
                     this.currentInsert.Properties.Add(new EntityAuditProperty {
                PropertyName = x.Name,
                OldValue     = String.Empty,
                NewValue     = this.ObjectToString(context, x.CurrentValue)
            })
                     );

            base.OnPreInsert(context, entry);
        }
 protected virtual void OnAuditStoreInsert(EntityAudit audit, DbContext context, DbEntityEntry entry)
 {
     auditContext.Audits.Add(audit);
 }