Ejemplo n.º 1
0
        private void SyncRates(List <Rate> list)
        {
            Object lockObject = new Object();

            lock (lockObject)
            {
                Debug.WriteLine("MessagingCenter: GetLocal recieved with Rates Count: {0}", list.Count());
                Intialize(list.ToList());
                ExchangeRateService.SyncRemoteRates(LastUpdate).ContinueWith(r =>
                {
                    Intialize(r.Result.ToList());
                    Debug.WriteLine("MessagingCenter:  ExchangeRateService.SyncRemoteRates Complete Rates Count: {0}",
                                    r.Result.Count());
                });
            }
        }
Ejemplo n.º 2
0
        public RatesHostViewModel()
        {
            TabName        = AppResources.TabNameRates;
            IsBusy         = true;
            OnRefreshClick = new Command(() =>
            {
                var connection = DependencyService.Get <INetworkConnectionInfo>();
                if (!connection.IsOnline())
                {
                    MessagingCenter.Send <RatesHostViewModel, bool>(this, "NoConnection", true);
                }
                else
                {
                    IsBusy = true;
                    ExchangeRateService.SyncRemoteRates(LastUpdate).ContinueWith(r =>
                    {
                        Intialize(r.Result.ToList());
                    });
                }
            });

            MessagingCenter.Subscribe <MainPageViewModel, IEnumerable <Rate> >(this, "GetLocal", (model, list) =>
            {
                SyncRates(list.ToList());
            });

            MessagingCenter.Subscribe <App, bool> (this, "ShowBusyIndicatorOnResume", (model, showBusy) =>
            {
                IsBusy = showBusy;
            });

            MessagingCenter.Subscribe <App, IEnumerable <Rate> >(this, "SyncOnResume", (model, list) =>
            {
                SyncRates(list.ToList());
            });
        }