public async Task <IActionResult> Exchange([FromBody] ExchangeRequest request) { _logger.LogInformation( $"Omregn beløbet {request.Amount} med fra valuta \"{request.FromCurrencyCode}\" til valuta \"{request.ToCurrencyCode}\""); if (!ModelState.IsValid) { return(BadRequest()); } var result = await _exchangeService.Exchange(request.Amount, request.FromCurrencyCode, request.ToCurrencyCode); var responseConfig = new HALModelConfig { LinkBase = $"{Request.Scheme}://{Request.Host.ToString()}", ForceHAL = Request.ContentType == "application/hal+json" }; var response = new HALResponse(responseConfig); response.AddEmbeddedResource("result", result); response.AddLinks( new Link("self", "/api/Exchange", null, "POST"), new Link("fromCurrency", $"/api/CurrencyRates/{request.FromCurrencyCode}"), new Link("toCurrency", $"/api/CurrencyRates/{request.ToCurrencyCode}") ); return(this.HAL(response)); }
internal async Task <BrokerExchangeResult> CreateExchange(BrokerExchangeParams model) { var exchange = await _exchangeService.Exchange(model); return(exchange); }
public async Task <IActionResult> Exchange([FromBody] BrokerExchangeParams model) { var res = await _exchangeService.Exchange(model); return(Ok(res)); }
public ICurrencyExpression reduce(ICurrencyExpression source, string to) { return(_exchangeService.Exchange(source, to)); }