Exemplo n.º 1
0
        public List <CoreAuditRecordDetail> GetEntityColumnChangedInfo(PropertyValues newValues, PropertyValues oldValues)
        {
            var auditRecordDetails    = new List <CoreAuditRecordDetail>();
            var newRelationShipValues = GetRelationshipColumnText(newValues);
            var oldRelationShipValues = GetRelationshipColumnText(oldValues);

            foreach (var property in newValues.Properties)
            {
                var newValue = string.Empty;
                var oldValue = string.Empty;
                if (!newRelationShipValues.ContainsKey(property.Name))
                {
                    newValue = newValues[property.Name] != null ? newValues[property.Name].ToString() : string.Empty;
                    oldValue = oldValues[property.Name] != null ? oldValues[property.Name].ToString() : String.Empty;
                }
                else
                {
                    newValue = newRelationShipValues[property.Name];
                    oldValue = oldRelationShipValues[property.Name];
                }
                if (newValue != oldValue)
                {
                    var auditRecordDetail = new CoreAuditRecordDetail
                    {
                        ColumnName = property.Name,
                        NewValue   = newValue,
                        OldValue   = oldValue
                    };
                    auditRecordDetails.Add(auditRecordDetail);
                }
            }
            return(auditRecordDetails);
        }
Exemplo n.º 2
0
        private List <CoreAuditRecordDetail> GetEntityColumnValues(PropertyValues newValues)
        {
            var auditRecordDetails = new List <CoreAuditRecordDetail>();
            var keys = newValues.EntityType.FindPrimaryKey();

            foreach (var property in newValues.Properties)
            {
                var oldValue = string.Empty;
                var newValue = newValues[property.Name];
                if (newValue != null && keys.Properties.Count(t => t.Name == property.Name) == 0)
                {
                    var auditRecordDetail = new CoreAuditRecordDetail
                    {
                        ColumnName = property.Name,
                        NewValue   = newValue.ToString(),
                        OldValue   = oldValue
                    };
                    auditRecordDetails.Add(auditRecordDetail);
                }
            }
            return(auditRecordDetails);
        }