public CurrencyController(ICurrencyConverterService currencyConverterService, IRequestLoggerService requestLoggerService, CurrencyConverterContext context) { _currencyConverterService = currencyConverterService; _requestLoggerService = requestLoggerService; _context = context; }
private void MigrateDatabase() { using (var dbContext = new CurrencyConverterContext()) { dbContext.Database.Migrate(); } }
private static void CleanRatesTable() { using (var dbContext = new CurrencyConverterContext()) { var deleteQuery = $"delete from {nameof(dbContext.Rates)}"; dbContext.Database.ExecuteSqlCommand(deleteQuery); } }
public RateService(ILoggerFactory loggerFactory, IDoubleFlow cache, IHttpClientFactory clientFactory, IOptions <CurrencyLayerOptions> options, CurrencyConverterContext context) { _cache = cache; _clientFactory = clientFactory; _context = context; _logger = loggerFactory.CreateLogger <RateService>(); _options = options.Value; }
private static void InsertNewRate(string usdCurrencyName, decimal usdRateValue) { using (var dbContext = new CurrencyConverterContext()) { var usdRate = new RateValue { RateValueId = 1, Currency = usdCurrencyName, Value = usdRateValue }; dbContext.Rates.Add(usdRate); dbContext.SaveChanges(); } }
public async Task <bool> LogRequest(string url, bool nbpApi, CurrencyConverterContext _context) { var log = new RequestLog() { Date = DateTime.Now, Request = String.Concat(nbpApi ? Commons.NBP_ROUTE : Commons.API_ROUTE, url) }; _context.RequestLogs.Add(log); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(false); } return(true); }
public DummyController(CurrencyConverterContext ctx) { _ctx = ctx; }
public CurrencyConverterRepo(CurrencyConverterContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }