private async Task GetCoinInfo(HttpContext context, Match m) { var coinType = (CoinType)CoinType.Parse(typeof(CoinType), m.Groups["coinType"]?.Value, true); var coinInfo = cf.Run(con => coinInfoRepo.GetCoinInfo(con, coinType)); if (coinInfo == null || DateTime.Now.Subtract(coinInfo.Updated).TotalMinutes > 5) { coinInfo = GetCoinInfoFromCryptoCompare(coinType); cf.RunTx((con, tx) => coinInfoRepo.AddCoinInfo(con, tx, coinInfo)); } var response = new CoinInfoResponse { CoinType = coinInfo.CoinType.ToString(), Name = coinInfo.Name, PriceBTC = coinInfo.PriceBTC, PriceUSD = coinInfo.PriceUSD }; await SendJsonAsync(context, response); }