public async Task <string> ConvertCurrency(CurrenciesToConvert currencies) { CurrenciesToConvert toConv = new CurrenciesToConvert(currencies); toConv.Validation(); decimal value = await _repository.Convert(currencies.value1, currencies.value2, currencies.amount); return($"{currencies.currency2} = {String.Format("{0:N}", value)}"); }
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)); } }