private void ResettableValueCollection_PropertyChanging(object sender, System.ComponentModel.PropertyChangingEventArgs e) { if (OldValues.ContainsKey(e.PropertyName) || PropertyResetExeclusions.Contains(e.PropertyName)) { return; } OldValues[e.PropertyName] = GetPropertyValue(e.PropertyName); }
private void ResettableObject_PropertyChanging(object sender, PropertyChangingEventArgs e) { if (OldValues.ContainsKey(e.PropertyName) || PropertyResetExeclusions.Contains(e.PropertyName)) { return; } //store old value in OldValues OldValues[e.PropertyName] = GetPropertyValue(e.PropertyName); }
public Audit ToAudit(IUserService userService, ReflmgContext refContext) { var audit = new Audit(); audit.TableName = TableName; audit.OperationType = OperationType; audit.OperationDate = DateTime.UtcNow; var userLogin = userService?.GetCurrentDbUser(); Contributeur user = refContext.Contributeur.FirstOrDefault(p => p.Login == userLogin); if (user == null) { audit.UserName = userLogin; } else { audit.UserName = user.Prenom + " " + user.Nom; } audit.RecordKey = int.Parse(KeyValues.First().Value.ToString()); audit.RecordName = RecordName; List <AuditEntryDetail> detail = new List <AuditEntryDetail>(); OldValues.Keys.Union(NewValues.Keys).Distinct().ToList() .ForEach(key => detail.Add(new AuditEntryDetail() { Field = key })); foreach (var item in detail) { item.NewValue = NewValues.ContainsKey(item.Field) ? NewValues[item.Field] : null; item.OldValue = OldValues.ContainsKey(item.Field) ? OldValues[item.Field] : null; AuditDetail auditDetail = new AuditDetail(); auditDetail.Field = item.Field; auditDetail.NewValue = item.NewValue?.ToString(); auditDetail.OldValue = item.OldValue?.ToString(); audit.AuditDetail.Add(auditDetail); } return(audit); }