Example #1
0
        protected async override Task OnInitializedAsync()
        {
            if (Id != null)
            {
                Guid invoiceNumber = new Guid(Id);
                ViewTitle = "Edit Invoice";
                Invoice   = await InvoiceService.GetInvoice(invoiceNumber);
            }
            else
            {
                ViewTitle = "New Invoice";
                Invoice   = new Invoice
                {
                    DeliveryDate = DateTime.Now,
                    SettleDate   = DateTime.Now,
                    InvoiceDate  = DateTime.Now,
                    InvoiceVat   = "",
                    Client       = "",
                    Currency     = "",
                    ExchangeRate = ""
                };
            }

            Vats          = (await VatService.GetVats()).ToList();
            Currencies    = (await CurrencyService.GetCurrencies()).ToList();
            ExchangeRates = (await ExchangeRateService.GetExchangeRates()).ToList();
            Clients       = (await ClientService.GetClients()).ToList();
            Mapper.Map(Invoice, InvoiceViewModel);
        }
        public async Task <ActionResult <ExchangeRate> > GetExchangeRates()
        {
            IExchangeRateService exchangeRateService = new ExchangeRateService(_settings);
            var result = await exchangeRateService.GetExchangeRates();

            return(Ok(result));
        }
Example #3
0
        public async void Refresh()
        {
            Exchange exchangeRates = await ExchangeRateService.GetExchangeRates(BaseCurrency);

            if (exchangeRates != null)
            {
                ExchangeRates = exchangeRates;
            }
        }
        public async void Button_Clicked(object sender, EventArgs e)
        {
            var currencyFrom   = pickerConvertFrom.Items[pickerConvertFrom.SelectedIndex];
            var currencyTo     = pickerConvertTo.Items[pickerConvertTo.SelectedIndex];
            var exchangeAmount = int.Parse(txtCurrencyAmount.Text);



            var exchangeRates = await _exchangeRateService.GetExchangeRates(currencyFrom, currencyTo);


            var exchangeTo = _exchangeRateService.countriesDictionary[currencyTo];

            var rate = exchangeRates.rates[exchangeTo];

            var amount = _exchangeRateService.CaculateExchangeRate(exchangeAmount, rate).ToString();

            var message = $"{exchangeAmount} {currencyFrom} = $ {amount} {exchangeTo} ";

            lblexchangedAmount.Text = amount.ToString();
        }
        private async Task <ExchangeRate> LoadRates()
        {
            var exchangeRateService = new ExchangeRateService(_settings);

            return(await exchangeRateService.GetExchangeRates());
        }