public Task <IActionResult> Convert(decimal amount, string from, string to) => RatesApi.GetRateAsync(from + to) .OrElse(() => CurrencyLayer.GetRateAsync(from + to)) .Map(rate => amount * rate) .Map( Faulted: ex => StatusCode(500, Errors.UnexpectedError), Completed: result => Ok(result) as IActionResult);
public static Task <decimal> GetRate(string ccyPair) => CurrencyLayer.GetRate(ccyPair) .OrElse(() => Yahoo.GetRate(ccyPair));