public T Create(T entity)
        {
            using (var transaction = new TransactionScope())
            {
                var dbEntityEntry = _dbContext.Entry(entity);

                if (dbEntityEntry.State != EntityState.Detached)
                {
                    dbEntityEntry.State = EntityState.Added;
                }
                else
                {
                    _dbSet.Add(entity);
                }

                var auditLogService = new AuditLogger(_dbContext, _userId);
                auditLogService.AuditCreatedBefore(new List <IEntity> {
                    entity
                });

                _dbContext.SaveChanges();

                auditLogService.AuditCreatedAfter(new List <IEntity> {
                    entity
                });

                transaction.Complete();

                return(entity);
            }
        }
        public void Create(IEnumerable <T> entities)
        {
            using (var transaction = new TransactionScope())
            {
                foreach (var entity in entities)
                {
                    var dbEntityEntry = _dbContext.Entry(entity);

                    if (dbEntityEntry.State != EntityState.Detached)
                    {
                        dbEntityEntry.State = EntityState.Added;
                    }
                }

                _dbSet.AddRange(entities);

                var auditLogService = new AuditLogger(_dbContext, _userId);
                auditLogService.AuditCreatedBefore(entities.ToList <IEntity>());

                _dbContext.SaveChanges();

                auditLogService.AuditCreatedAfter(entities.ToList <IEntity>());

                transaction.Complete();
            }
        }