private async void toolbarItem_next()
        {
            ToolbarItems.Remove(tbiNext);
            _activityIndicator.IsRunning = true;
            _activityIndicator.IsVisible = true;

            //**NON C'E CONNESSIONE INTERNET**
            if (!CrossConnectivity.Current.IsConnected)
            {   //non connesso a internet
                var toast = DependencyService.Get <IToastNotificator>();
                await toast.Notify(ToastNotificationType.Error, "Errore", "Nessun accesso a internet", TimeSpan.FromSeconds(3));

                return;
            }

            foreach (var preferito in _preferiti)
            {
                //add corso
                var corso = new Corso()
                {
                    Insegnamento = preferito.Insegnamento, Codice = preferito.Codice, Docente = preferito.Docente,
                };
                await _service.AddCorso(corso);

                corso = await _service.GetCorso(corso);

                preferito.IdCorso = corso.Id;
                //add preferito
                await _service.AddPreferito(preferito);

                _db.Insert(preferito);
            }


            Settings.MieiCorsiCount = _db.GetAllMieiCorsi().Count();

            if (DateTime.Now.Hour > Settings.UpdateHour)             // && DateTime.Now.Minute > Settings.UpdateMinute)
            {
                _oggi = new DayViewModel()
                {
                    Data = DateTime.Today.AddDays(1)
                };
                _domani = new DayViewModel()
                {
                    Data = _oggi.Data.AddDays(1)
                };
                _dopodomani = new DayViewModel()
                {
                    Data = _domani.Data.AddDays(1)
                };
            }
            else
            {
                _oggi = new DayViewModel()
                {
                    Data = DateTime.Today
                };
                _domani = new DayViewModel()
                {
                    Data = _oggi.Data.AddDays(1)
                };
                _dopodomani = new DayViewModel()
                {
                    Data = _domani.Data.AddDays(1)
                };
            }

            DateTime[] arrayDate = new DateTime[] { _oggi.Data, _domani.Data, _dopodomani.Data };

            if (!CrossConnectivity.Current.IsConnected)               //non connesso a internet
            {
                var toast = DependencyService.Get <IToastNotificator>();
                await toast.Notify(ToastNotificationType.Error, "Errore", "Nessun accesso a internet", TimeSpan.FromSeconds(3));

                return;
            }
            else                //CONNESSIONE A INTERNET
            {
                foreach (var d in arrayDate)
                {
                    //Corsi generale, utenza + corsi
                    string s = await Web.GetOrarioGiornaliero(Settings.FacoltaDB, Settings.FacoltaId, 0, d.ToString("dd'/'MM'/'yyyy"));

                    List <CorsoGiornaliero> listaCorsi = Web.GetSingleOrarioGiornaliero(s, 0, d);

                    if (listaCorsi.Count() != 0)
                    {
                        TabbedHomeView.updateSingleCorso(_db, listaCorsi);
                    }
                }
            }

            _activityIndicator.IsRunning = false;
            _activityIndicator.IsVisible = false;

            if (Settings.BackgroundSync)
            {
                DependencyService.Get <INotification> ().BackgroundSync();
            }

            await Navigation.PushModalAsync(new MasterDetailView()
            {
                Service = _service
            });
        }
Exemple #2
0
        void _listView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            Logcat.Write(string.Format("{0}: {1}", "MASTERDETAIL", "click select menu item"));

            if (e.SelectedItem == null)                         // ensures we ignore this handler when the selection is just being cleared
            {
                return;
            }

            var menuItem = _listView.SelectedItem as OrariUnibg.Models.MenuItem;

            menuType = menuItem.MenuType;

            foreach (var x in _viewModel.MenuItems)
            {
                x.Selected = false;
            }

            Logcat.Write(string.Format("{0}: {1}", "MASTERDETAIL", "prima dello switch"));

            switch (menuItem.MenuType)
            {
            case MenuType.Home:
                if (mainView == null)
                {
                    mainView = new TabbedHomeView();
                }

                Logcat.Write(string.Format("{0}: {1}", "MASTERDETAIL", "HOME"));
                //	                _viewModel.MenuItems[0].Selected = true;

                Logcat.Write(string.Format("{0}: {1}", "MASTERDETAIL", "menu items count"));
                _viewModel.MenuItems.Where(x => x.Id == 0).FirstOrDefault().Selected = true;

                PageSelection = mainView;
                Logcat.Write(string.Format("{0}: {1}", "MASTERDETAIL", "page selection ok"));
                break;

            case MenuType.Giornaliero:
                if (selectGiornView == null)
                {
                    selectGiornView = new SelectGiornaliero();
                }

//	                _viewModel.MenuItems[1].Selected = true;
                _viewModel.MenuItems.Where(x => x.Id == 1).FirstOrDefault().Selected = true;
                PageSelection = selectGiornView;
                break;

            case MenuType.Completo:
                if (selectCompletoView == null)
                {
                    selectCompletoView = new SelectCompleto();
                }

//	                _viewModel.MenuItems[2].Selected = true;
                _viewModel.MenuItems.Where(x => x.Id == 2).FirstOrDefault().Selected = true;
                PageSelection = selectCompletoView;
                break;

            case MenuType.SuggerisciCorsi:
                if (suggerisciView == null)
                {
                    suggerisciView = new SuggerisciCorsiView();
                }

                _viewModel.MenuItems.Where(x => x.Id == 3).FirstOrDefault().Selected = true;
                PageSelection = suggerisciView;
                break;

            case MenuType.Impostazioni:
                if (impostazioniView == null)
                {
                    impostazioniView = new ImpostazioniView();
                }

//					_viewModel.MenuItems[3].Selected = true;
                _viewModel.MenuItems.Where(x => x.Id == 4).FirstOrDefault().Selected = true;
                PageSelection = impostazioniView;
                break;
            }

            ((ListView)sender).SelectedItem = null;
            //Page p = PageSelection;

            //MessagingCenter.Send<MasterView, Page>(this, "menuItem_clicked", p);
        }