public override async Task <int> SaveChangesAsync()
        {
            var test    = System.Threading.SynchronizationContext.Current;
            var result  = 0;
            var entries = this.ChangeTracker.Entries().Where(e => e.State.HasFlag(EntityState.Added) ||
                                                             e.State.HasFlag(EntityState.Modified) ||
                                                             e.State.HasFlag(EntityState.Deleted));
            var originalStates = new Dictionary <DbEntityEntry, EntityState>();

            foreach (var entry in entries)
            {
                try{
                    if (entry.State == EntityState.Modified)
                    {
                        DoAuditEntry.MakeUpdateJournalEntry(user, entry);
                    }
                    if (entry.State == EntityState.Added || entry.State == EntityState.Deleted)
                    {
                        DoAuditEntry.MakeAddJournalEntry(user, this, entry);
                    }
                }catch { continue; }
            }
            result = await base.SaveChangesAsync();

            return(result);
        }
        public override int SaveChanges()
        {
            var result  = 0;
            var entries = this.ChangeTracker.Entries().Where(e => e.State.HasFlag(EntityState.Added) ||
                                                             e.State.HasFlag(EntityState.Modified) ||
                                                             e.State.HasFlag(EntityState.Deleted));
            var originalStates = new Dictionary <DbEntityEntry, EntityState>();

            foreach (var entry in entries)
            {
                if (entry.Entity is GeneratorBase.MVC.Models.LoginAttempts)
                {
                    continue;
                }
                if (entry.State == EntityState.Modified)
                {
                    DoAuditEntry.MakeUpdateJournalEntry(user, entry);
                }
                if (entry.State == EntityState.Added || entry.State == EntityState.Deleted)
                {
                    DoAuditEntry.MakeAddJournalEntry(user, this, entry);
                }
            }
            result = base.SaveChanges();
            return(result);
        }
        public override int SaveChanges()
        {
            var result  = 0;
            var entries = this.ChangeTracker.Entries().Where(e => e.State.HasFlag(EntityState.Added) ||
                                                             e.State.HasFlag(EntityState.Modified) ||
                                                             e.State.HasFlag(EntityState.Deleted));
            var originalStates = new Dictionary <DbEntityEntry, EntityState>();

            //var entry = entries.FirstOrDefault();
            //if (entry != null)
            //{
            //    if (entry.State == EntityState.Modified)
            //        DoAuditEntry.MakeUpdateJournalEntry(user, entry);
            //    if (entry.State == EntityState.Added || entry.State == EntityState.Deleted)
            //        DoAuditEntry.MakeAddJournalEntry(user, null, entry);
            //}
            foreach (var entry in entries)
            {
                try
                {
                    if (entry.State == EntityState.Modified)
                    {
                        DoAuditEntry.MakeUpdateJournalEntry(user, entry);
                    }
                    if (entry.State == EntityState.Added || entry.State == EntityState.Deleted)
                    {
                        DoAuditEntry.MakeAddJournalEntry(user, null, entry);
                    }
                }
                catch { continue; }
            }
            result = base.SaveChanges();
            return(result);
        }