Exemple #1
0
        public async Task <CurrencyRateResponse> CreateAsync([FromBody] CurrencyRateRequest request)
        {
            try
            {
                await _currencyRateService.CreateAsync(request.BaseAsset, request.QuoteAsset, request.Rate);
            }
            catch (EntityAlreadyExistsException)
            {
                return(new CurrencyRateResponse {
                    ErrorCode = RateErrorCode.RateAlreadyExists
                });
            }

            return(new CurrencyRateResponse
            {
                BaseAsset = request.BaseAsset,
                QuoteAsset = request.QuoteAsset,
                Rate = request.Rate,
                ErrorCode = RateErrorCode.None
            });
        }