private CurrencyPrice FetchCachedPrice(Currency from, Currency to)
 {
     using (var context = new InvestmentTrackerDbContext())
     {
         var currencyPrice = context.CurrencyPrice.Where(x => x.From == from.ToString() && x.To == to.ToString())
                             .SingleOrDefault();
         return((currencyPrice != null &&
                 (currencyPrice.LastUpdated - DateTime.Now).Hours < 3) ? currencyPrice : null);
     }
 }
 private void UpateCache(Currency from, Currency to, decimal price)
 {
     using (var context = new InvestmentTrackerDbContext())
     {
         context.CurrencyPrice.AddOrUpdate(new CurrencyPrice
         {
             From        = from.ToString(),
             To          = to.ToString(),
             LastUpdated = DateTime.Now,
             Price       = price
         });
         context.SaveChanges();
     }
 }