public async Task <ConversionModel> Handle(ObtenerConversionRequest request, CancellationToken cancellationToken)
        {
            logger.LogInformation("Obtener conversion de: {from} a {to}", request.From, request.To);

            var result = await service.ObtenerConversionAsync(request.From, request.To);

            await loggingService.WriteLine(result.Ratio.ToString());

            return(mapper.Map <ConversionModel>(result));
        }
Exemplo n.º 2
0
        public async Task <CurrencyModel> ObtenerConversion(CurrencyModel currency)
        {
            string idDolar = "USD";

            try
            {
                var conversionDataModel = await monedasApiService.ObtenerConversionAsync(currency.CurrencyId, idDolar);

                await loggingService.WriteLine(conversionDataModel.Ratio.ToString());

                currency.Conversion = mapper.Map <ConversionModel>(conversionDataModel);
            }
            catch
            {
                currency.Conversion = null;
            }

            return(currency);
        }
        public async Task <IEnumerable <CurrencyModel> > ObtenerConversiones(IEnumerable <CurrencyModel> currencies)
        {
            string idDolar = "USD";

            foreach (var currency in currencies)
            {
                try
                {
                    var conversionDataModel = await monedasApiService.ObtenerConversionAsync(currency.CurrencyId, idDolar);

                    await loggingService.WriteLine(conversionDataModel.Ratio.ToString());

                    currency.Conversion = mapper.Map <ConversionModel>(conversionDataModel);
                }
                catch
                {
                    currency.Conversion = null;
                }
            }

            return(currencies);
        }
Exemplo n.º 4
0
        public void WriteLine(string data)
        {
            service.WriteLine(data).Wait();

            Assert.Pass();
        }