Exemple #1
0
        public async ValueTask <Result <MoneyAmount, ProblemDetails> > Convert(Currencies sourceCurrency, Currencies targetCurrency, decimal value)
        {
            var(_, isFailure, results, error) = await Convert(sourceCurrency, targetCurrency, new List <decimal>(1) { value });

            if (isFailure)
            {
                return(Result.Failure <MoneyAmount, ProblemDetails>(error));
            }

            if (results.TryGetValue(new MoneyAmount(value, targetCurrency), out var result))
            {
                return(Result.Success <MoneyAmount, ProblemDetails>(result));
            }

            return(ProblemDetailsBuilder.FailAndLogNoQuoteFound <MoneyAmount>(_logger, sourceCurrency.ToString() + targetCurrency));
        }