private Task <HttpResponseMessage> FallbackAction( DelegateResult <HttpResponseMessage> responseToFailedRequest, Context context, CancellationToken cancellationToken) { var uri = responseToFailedRequest.Result.RequestMessage.RequestUri.ToString(); var metalType = uri.Contains("GOLD") ? Metal.Gold : Metal.Silver; var metalPrices = _metalsPricesProvider.Get(metalType).Result; HttpResponseMessage httpResponseMessage = new HttpResponseMessage(responseToFailedRequest.Result.StatusCode) { Content = new StringContent(metalPrices, Encoding.UTF8, "application/json") }; return(Task.FromResult(httpResponseMessage)); }
public async Task <IActionResult> Get(Metal metal, DateTime start, DateTime end) { var json = await _metalsPricesProvider.Get(metal); //should I move these extension methods invokes fom API? var metalPrices = json .Deserialize() .Map(start, end); if (metalPrices == null) { return(NoContent()); } return(Ok(metalPrices)); }