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); } }
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); }