Example #1
0
        public async void ConvertCurrency()
        {
            CurrenciesToConvert conv = new CurrenciesToConvert
            {
                currency1 = "Real Brasileiro (BRL)",
                value1    = 4.069296M,
                amount    = 1,
                currency2 = "Euro Europa (EUR)",
                value2    = 0.89612M
            };
            var converted = await _service.ConvertCurrency(conv);

            Console.WriteLine(converted);
        }
        public async Task <IActionResult> Post([FromBody] CurrenciesToConvert currencies)
        {
            try
            {
                if (currencies != null)
                {
                    var resultado = await _services.ConvertCurrency(currencies);

                    return(Ok(resultado));
                }
                else
                {
                    return(BadRequest("Informe os valores"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }