示例#1
0
        public static Task <EntityEntry <TEntity> > AddWithContextAsync <TEntity>(this DbSet <TEntity> dbset, RequestContextCore context, TEntity entity, CancellationToken cancellationToken = default)
            where TEntity : EntityCore
        {
            var currentDateTime = DateTime.Now;

            entity.CreatedAt = currentDateTime;
            entity.UpdatedAt = currentDateTime;
            entity.CreatedBy = context.UserId;
            entity.UpdatedBy = context.UserId;
            return(dbset.AddAsync(entity, cancellationToken));
        }
示例#2
0
 public static EntityEntry <TEntity> UpdateWithContext <TEntity>(this DbSet <TEntity> dbset, RequestContextCore context, TEntity entity)
     where TEntity : EntityCore
 {
     entity.UpdatedAt = DateTime.Now;
     entity.UpdatedBy = context.UserId;
     return(dbset.Update(entity));
 }
示例#3
0
        public static EntityEntry <TEntity> AddWithContext <TEntity>(this DbSet <TEntity> dbset, RequestContextCore context, TEntity entity)
            where TEntity : EntityCore
        {
            var currentDateTime = DateTime.Now;

            entity.CreatedAt = currentDateTime;
            entity.UpdatedAt = currentDateTime;
            entity.CreatedBy = context.UserId;
            entity.UpdatedBy = context.UserId;
            return(dbset.Add(entity));
        }