public LoginViewModel() { loginService = new LoginService(); courseService = new CourseService(); userDao = new UserDao(); courseDao = new CourseDao(); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching (UIApplication app, NSDictionary options) { userDao = new UserDao (); courseDao = new CourseDao (); this.window = new UIWindow (UIScreen.MainScreen.Bounds); var rootNavigationController = new UINavigationController (); if (userDao.tokenExists () && courseDao.existCourses ()) { CoursesViewController courseView = new CoursesViewController(); rootNavigationController.PushViewController(courseView,false); } else { MonoMobilisViewController loginView = new MonoMobilisViewController(); rootNavigationController.PushViewController(loginView,false); } //MonoMobilisViewController loginView = new MonoMobilisViewController(); //rootNavigationController.PushViewController(loginView,false); this.window.RootViewController = rootNavigationController; this.window.MakeKeyAndVisible(); ServiceLocator.Dispatcher = new DispatchAdapter(this); return true; }
public CoursesViewModel() { courseDao = new CourseDao(); userDao = new UserDao(); classService = new ClassService(); classDao = new ClassDao(); listContent = courseDao.getAllCourses(); }
void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e) { CourseDao courseDao = new CourseDao(); // se a navegação não for para a MainPage(login) não há mudança na navegação if (e.Uri.ToString().Contains("/MainPage.xaml") != true) return; if (courseDao.existCourses()) { e.Cancel = true; RootFrame.Dispatcher.BeginInvoke(delegate { System.Diagnostics.Debug.WriteLine("TO COURSES"); RootFrame.Navigate(new Uri("/Views/CoursePage.xaml", UriKind.Relative)); }); } else { System.Diagnostics.Debug.WriteLine("TO LOGIN"); e.Cancel = false; return; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); courseDao = new CourseDao(); userDao = new UserDao(); int flag = Intent.GetIntExtra("content",0); if (flag == TERMINATE) { this.Finish(); } else { try { User user = userDao.getUser(); if ((user.token != null) && user.autoLogin) { Log.Info("mobilis","user token = " + user.token + "auto login on"); intent = new Intent(this, typeof(CoursesActivity)); StartActivity(intent); } else { Log.Info("mobilis", "auto login off"); intent = new Intent(this, typeof(LoginActivity)); StartActivity(intent); } } catch (Exception e) { Log.Info("mobilis", "setup Exception"); intent = new Intent(this, typeof(LoginActivity)); StartActivity(intent); } } }