private void ApplyAuditInfoRules() { // Approach via @julielerman: http://bit.ly/123661P foreach (var entry in this.ChangeTracker.Entries() .Where( e => e.Entity is IAuditInfo && ((e.State == EntityState.Added) || (e.State == EntityState.Modified)))) { var entity = (IAuditInfo)entry.Entity; if (entry.State == EntityState.Added && entity.CreatedOn == default(DateTime)) { entity.CreatedOn = GlobalDateTimeInfo.GetDateTimeUtcNow(); } else { entity.ModifiedOn = GlobalDateTimeInfo.GetDateTimeUtcNow(); } } }
public T Get <T>(string itemName, Func <T> getDataFunc, int durationInSeconds) where T : class { if (HttpRuntime.Cache[itemName] == null) { lock (LockObject) { if (HttpRuntime.Cache[itemName] == null) { var data = getDataFunc(); HttpRuntime.Cache.Insert( itemName, data, null, GlobalDateTimeInfo.GetDateTimeUtcNow().AddSeconds(durationInSeconds), Cache.NoSlidingExpiration); } } } return((T)HttpRuntime.Cache[itemName]); }
public ApplicationUser() { // This will prevent UserManager.CreateAsync from causing exception this.CreatedOn = GlobalDateTimeInfo.GetDateTimeUtcNow(); }
public void Delete(T entity) { entity.IsDeleted = true; entity.DeletedOn = GlobalDateTimeInfo.GetDateTimeUtcNow(); }