private async Task RefreshRates() { this.IsBusy = true; IBaseResponse <IRatesWrapper> newRatesResponse = await this._webServiceManager.GetAndParse <IRatesWrapper>("exchange-rates", new JsonConverter[] { new RateConverter(), new RatesWrapperConverter() }); if (newRatesResponse != null && newRatesResponse.IsValid() && newRatesResponse.Result.Value != null && newRatesResponse.Result.Value.Count > 0) { this.AllRates.ReplaceRange(newRatesResponse.Result.Value.OrderedRatesList()); await this._xtradeRepository.InsertRatesAsync(this.AllRates); this.IsBusy = false; this.OnRefreshFinish?.Invoke(this, "Rates updated"); } else { this.IsBusy = false; this.OnRefreshFinish?.Invoke(this, "Could not refresh exchange rates"); } }
private async Task RefreshSelectedRate() { IsBusy = true; IBaseResponse <IRatesWrapper> newRatesResponse = await this._webServiceManager.GetAndParse <IRatesWrapper>("exchange-rates?currencyCode=" + this._selectedRate.CurrencyCode, new JsonConverter[] { new RateConverter(), new RatesWrapperConverter() }); if (newRatesResponse != null && newRatesResponse.IsValid() && newRatesResponse.Result.Value != null && newRatesResponse.Result.Value.Count > 0) { this.SelectedRate = newRatesResponse.Result.Value.FirstOrDefault(); await this._xtradeRepository.InsertRateAsync(this._selectedRate); this.IsBusy = false; this.OnRefreshFinish?.Invoke(this, "Rate updated"); } else { this.IsBusy = false; this.OnRefreshFinish?.Invoke(this, "Could not refresh exchange rate"); } }
public async void RefreshSelectedRate() { this.IsDataRefreshing = true; IBaseResponse <IRatesWrapper> newRatesResponse = await this._webServiceManager.GetAndParse <IRatesWrapper>("exchange-rates?currencyCode=" + this._selectedRateCode, new JsonConverter[] { new RateConverter(), new RatesWrapperConverter() }); if (newRatesResponse != null && newRatesResponse.IsValid() && newRatesResponse.Result.Value != null && newRatesResponse.Result.Value.Count > 0) { this.SelectedRate = newRatesResponse.Result.Value.FirstOrDefault(); await this._xtradeRepository.InsertRateAsync(this.SelectedRate); this.OnViewModelDataChanged?.Invoke(this, null); this.IsDataRefreshing = false; this.OnRefreshSuccess?.Invoke(this, "Rate updated"); } else { this.IsDataRefreshing = false; this.OnRefreshError?.Invoke(this, "Could not refresh exchange rate"); } }
public async void RefreshRates() { this.IsDataRefreshing = true; IBaseResponse <IRatesWrapper> newRatesResponse = await this._webServiceManager.GetAndParse <IRatesWrapper>("exchange-rates", new JsonConverter[] { new RateConverter(), new RatesWrapperConverter() }); if (newRatesResponse != null && newRatesResponse.IsValid() && newRatesResponse.Result.Value != null && newRatesResponse.Result.Value.Count > 0) { this.AllRates = newRatesResponse.Result.Value.OrderedRatesList(); await this._xtradeRepository.InsertRatesAsync(this.AllRates); this.OnViewModelDataChanged?.Invoke(this, null); this.IsDataRefreshing = false; this.OnRefreshSuccess?.Invoke(this, "Rates updated"); } else { this.IsDataRefreshing = false; this.OnRefreshError?.Invoke(this, "Could not refresh exchange rates"); } }