public override void SaveAuditedEntity(AuditedEntity auditedEntity)
        {
            string userName = System.Threading.Thread.CurrentPrincipal.Identity.Name;
            var    audit    = new AuditRecord
            {
                Action              = (byte)auditedEntity.Action,
                AuditDate           = DateTime.Now,
                EntityTable         = auditedEntity.EntityType.Name,
                EntityTableKey      = auditedEntity.EntityKey,
                AssociationTable    = auditedEntity.ParentEntityType.Name,
                AssociationTableKey = auditedEntity.ParentKey,
                UserName            = userName
            };

            foreach (var modifiedProperty in auditedEntity.ModifiedProperties)
            {
                if (modifiedProperty.DisplayName.Trim() != "Date Updated" &&
                    modifiedProperty.DisplayName.Trim() != "User Updated Id")
                {
                    audit.AuditRecordFields.Add(
                        new AuditRecordField
                    {
                        MemberName = modifiedProperty.DisplayName,
                        OldValue   = modifiedProperty.OldValue,
                        NewValue   = modifiedProperty.NewValue
                    });
                }
            }
            if (audit.AuditRecordFields.Count > 0)
            {
                AuditRecords.InsertOnSubmit(audit);
            }
        }
Esempio n. 2
0
        public override void SaveAuditedEntity(AuditedEntity auditedEntity)
        {
            var audit = new AuditRecord
            {
                Action      = (byte)auditedEntity.Action,
                AuditDate   = DateTime.Now,
                ParentTable = auditedEntity.ParentEntityType.Name,
                ParentKey   = auditedEntity.ParentKey,
                Table       = auditedEntity.EntityType.Name,
                TableKey    = auditedEntity.EntityKey,
                UserName    = "******",
            };

            foreach (var modifiedProperty in auditedEntity.ModifiedProperties)
            {
                audit.AuditRecordProperties.Add(
                    new AuditRecordProperty
                {
                    PropertyName = modifiedProperty.DisplayName,
                    OldValue     = modifiedProperty.OldValue,
                    NewValue     = modifiedProperty.NewValue
                });
            }

            if (audit.AuditRecordProperties.Count > 0)
            {
                AuditRecords.InsertOnSubmit(audit);
            }
        }