Пример #1
0
        public static void Update <TEntity>(this OnlineStoreDbContext dbContext, TEntity entity, IUserInfo userInfo) where TEntity : class, IAuditableEntity
        {
            if (entity is IAuditableEntity cast)
            {
                if (string.IsNullOrEmpty(cast.LastUpdateUser))
                {
                    cast.LastUpdateUser = userInfo.UserName;
                }

                if (!cast.LastUpdateDateTime.HasValue)
                {
                    cast.LastUpdateDateTime = DateTime.Now;
                }
            }

            dbContext.Set <TEntity>().Update(entity);
        }
Пример #2
0
 public static void Remove <TEntity>(this OnlineStoreDbContext dbContext, TEntity entity) where TEntity : class, IAuditableEntity
 => dbContext.Set <TEntity>().Remove(entity);