Exemplo n.º 1
0
        private static async Task CreateCurrencyIfNotExistAsync(BaseCleanArchitectureProjectDbContext dbContext, Currency currency, CancellationToken cancellationToken)
        {
            var exist = dbContext.Set <Currency>().FirstOrDefault(c => c.ISO == currency.ISO);

            if (exist == null)
            {
                await dbContext.Set <Currency>().AddAsync(currency, cancellationToken);
            }
        }
Exemplo n.º 2
0
        public virtual async Task <T> AddAsync(T entity, CancellationToken cancellationToken = default)
        {
            await ValidateAsync(entity, cancellationToken);

            await _dbContext.Set <T>().AddAsync(entity, cancellationToken);

            await _dbContext.SaveChangesAsync(cancellationToken);

            return(entity);
        }