Ejemplo n.º 1
0
        public async Task <ActionResult> GetHomeCurrencyAsync(string sourceCurrencyCode, string destinationCurrencyCode)
        {
            if (string.IsNullOrWhiteSpace(sourceCurrencyCode) || string.IsNullOrWhiteSpace(destinationCurrencyCode))
            {
                return(this.Failed(I18N.BadRequest, HttpStatusCode.BadRequest));
            }

            if (sourceCurrencyCode == destinationCurrencyCode)
            {
                return(this.Ok(1.0));
            }

            var meta = await AppUsers.GetCurrentAsync().ConfigureAwait(true);

            decimal exchangeRate = await Receipts.GetExchangeRateAsync(this.Tenant, meta.OfficeId, sourceCurrencyCode, destinationCurrencyCode).ConfigureAwait(true);

            return(this.Ok(exchangeRate));
        }