Ejemplo n.º 1
0
 public void AddChangesAfterSave(LogDatabaseDetails changes)
 {
     if (changes != null)
     {
         LogUserActionModel.DatabaseDetails = LogUserActionModel.DatabaseDetails ?? new LogDatabaseDetails();
         if (changes.Added.Count != 0)
         {
             LogUserActionModel.DatabaseDetails.Added = LogUserActionModel.DatabaseDetails.Added ?? new List <LogDatabaseObject>();
             LogUserActionModel.DatabaseDetails.Added.AddRange(changes.Added);
         }
         if (changes.Modified.Count != 0)
         {
             LogUserActionModel.DatabaseDetails.Modified = LogUserActionModel.DatabaseDetails.Modified ?? new List <LogDatabaseObject>();
             LogUserActionModel.DatabaseDetails.Modified.AddRange(changes.Modified);
         }
         if (changes.Deleted.Count != 0)
         {
             LogUserActionModel.DatabaseDetails.Deleted = LogUserActionModel.DatabaseDetails.Deleted ?? new List <LogDatabaseObject>();
             LogUserActionModel.DatabaseDetails.Deleted.AddRange(changes.Deleted);
         }
     }
 }
Ejemplo n.º 2
0
        public async override Task <int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            if (LogUserActionService == null)
            {
                return(await base.SaveChangesAsync());
            }

            LogDatabaseDetails changes = null;

            try
            {
                changes = LogUserActionService.GetChangesBeforeSave(this);
            }
            catch (Exception)
            {
            }

            var result = await base.SaveChangesAsync();

            LogUserActionService.AddChangesAfterSave(changes);

            return(result);
        }
Ejemplo n.º 3
0
        public override int SaveChanges()
        {
            if (LogUserActionService == null)
            {
                return(base.SaveChanges());
            }

            LogDatabaseDetails changes = null;

            try
            {
                changes = LogUserActionService.GetChangesBeforeSave(this);
            }
            catch (Exception)
            {
            }

            var result = base.SaveChanges();

            LogUserActionService.AddChangesAfterSave(changes);

            return(result);
        }