11using System . Diagnostics . CodeAnalysis ;
2+ using System . Text . Json . Serialization ;
23
34using EntityChange ;
45
@@ -16,14 +17,17 @@ public class AuditRecord<TKey>
1617 /// <value>
1718 /// The key for the entity.
1819 /// </value>
19- [ NotNull ] public TKey Key { get ; set ; } = default ! ;
20+ [ NotNull ]
21+ [ JsonPropertyName ( "key" ) ]
22+ public TKey Key { get ; set ; } = default ! ;
2023
2124 /// <summary>
2225 /// Gets or sets the entity name.
2326 /// </summary>
2427 /// <value>
2528 /// The entity name.
2629 /// </value>
30+ [ JsonPropertyName ( "entity" ) ]
2731 public string Entity { get ; set ; } = null ! ;
2832
2933 /// <summary>
@@ -32,6 +36,8 @@ public class AuditRecord<TKey>
3236 /// <value>
3337 /// The entity display name.
3438 /// </value>
39+ [ JsonPropertyName ( "displayName" ) ]
40+ [ JsonIgnore ( Condition = JsonIgnoreCondition . WhenWritingNull ) ]
3541 public string ? DisplayName { get ; set ; }
3642
3743 /// <summary>
@@ -40,22 +46,27 @@ public class AuditRecord<TKey>
4046 /// <value>
4147 /// The description of the entity.
4248 /// </value>
49+ [ JsonPropertyName ( "description" ) ]
50+ [ JsonIgnore ( Condition = JsonIgnoreCondition . WhenWritingNull ) ]
4351 public string ? Description { get ; set ; }
4452
4553 /// <summary>
46- /// Gets or sets the date the change activity occured .
54+ /// Gets or sets the date the change activity occurred .
4755 /// </summary>
4856 /// <value>
49- /// The date the change activity occured .
57+ /// The date the change activity occurred .
5058 /// </value>
59+ [ JsonPropertyName ( "activityDate" ) ]
5160 public DateTimeOffset ActivityDate { get ; set ; }
5261
5362 /// <summary>
54- /// Gets or sets the username that initiated the activity.
63+ /// Gets or sets the user name that initiated the activity.
5564 /// </summary>
5665 /// <value>
57- /// The username that initiated the activity.
66+ /// The user name that initiated the activity.
5867 /// </value>
68+ [ JsonPropertyName ( "activityBy" ) ]
69+ [ JsonIgnore ( Condition = JsonIgnoreCondition . WhenWritingNull ) ]
5970 public string ? ActivityBy { get ; set ; }
6071
6172 /// <summary>
@@ -64,6 +75,8 @@ public class AuditRecord<TKey>
6475 /// <value>
6576 /// The type of operation.
6677 /// </value>
78+ [ JsonPropertyName ( "operation" ) ]
79+ [ JsonConverter ( typeof ( JsonStringEnumConverter < AuditOperation > ) ) ]
6780 public AuditOperation Operation { get ; set ; }
6881
6982 /// <summary>
@@ -72,6 +85,7 @@ public class AuditRecord<TKey>
7285 /// <value>
7386 /// The list of changes.
7487 /// </value>
88+ [ JsonPropertyName ( "changes" ) ]
89+ [ JsonIgnore ( Condition = JsonIgnoreCondition . WhenWritingNull ) ]
7590 public IReadOnlyCollection < ChangeRecord > ? Changes { get ; set ; }
76-
7791}
0 commit comments