var i = new Invoice(); i.Created(user);
i.Modified(user);
public partial class Invoice : IAuditable { }
public interface IAuditable { DateTime UpdatedOn { get; set; } string UpdatedBy { get; set; } DateTime CreatedOn { get; set; } string CreatedBy { get; set; } } public static class IAuditableExtension { public static void Audit(this IAuditable e, bool createNew, string byUser) { if (e == null) return; var dtNow = DateTime.UtcNow; if (createNew) { e.CreatedOn = dtNow; e.CreatedBy = byUser; } e.UpdatedOn = DateTime.UtcNow; e.UpdatedBy = byUser; } }