Пример #1
0
        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();
                }
            }
        }
Пример #2
0
        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]);
        }
Пример #3
0
 public ApplicationUser()
 {
     // This will prevent UserManager.CreateAsync from causing exception
     this.CreatedOn = GlobalDateTimeInfo.GetDateTimeUtcNow();
 }
Пример #4
0
 public void Delete(T entity)
 {
     entity.IsDeleted = true;
     entity.DeletedOn = GlobalDateTimeInfo.GetDateTimeUtcNow();
 }