public MainPageViewModel(ICharacterRepository repository, IAuthenticationHelper helper, INavigationService service) { _repository = repository; _helper = helper; _service = service; Characters = new ObservableCollection <CharacterViewModel>(); DetailsPageCommand = new RelayCommand(o => { _service.Navigate(typeof(CharacterPage), o); }); SignInOutCommand = new RelayCommand(async o => { if (_account != null) { await _helper.SignOutAsync(_account); _account = null; Characters.Clear(); } else { _account = await _helper.SignInAsync(); if (_account != null) { await Initialize(); } } }); }
public AddProjectPageViewModel(IProjectAPI _projectAPI, IAuthenticationHelper _helper, INavigationService _service, ILocationAPI _locationAPI, ISkillAPI _skillAPI, IAttachmentAPI _attachmentAPI) { projectAPI = _projectAPI; helper = _helper; service = _service; skillAPI = _skillAPI; attachmentAPI = _attachmentAPI; locationAPI = _locationAPI; account = CommonAttributes.account; UserName = account.UserName; SignInOutButtonText = account == null ? "Sign In" : "Sign Out"; //init countries list Countries = new ObservableCollection <string>(GetCountryList()); SignInOutCommand = new RelayCommand(async o => { //sign out if (account != null) { await helper.SignOutAsync(account); account = null; CommonAttributes.account = account; SignInOutButtonText = "Sign In"; service.Navigate(typeof(LogInPage), null); } else //sign in { account = await helper.SignInAsync(); if (account != null) { CommonAttributes.account = account; UserName = account.UserName; SignInOutButtonText = "Sign Out"; } } }); MenuOptions = new HamburgerMenuOptionsFactory(CommonAttributes.account).MenuOptions; }
public SearchPageViewModel(IAuthenticationHelper _helper, IProjectAPI _projectAPI) { projectAPI = _projectAPI; helper = _helper; account = CommonAttributes.account; UserName = account.UserName; SignInOutButtonText = account == null ? "Sign In" : "Sign Out"; ProjectResults = new ObservableCollection <ProjectViewModel>(); UserResults = new ObservableCollection <UserDTO>(); SignInOutCommand = new RelayCommand(async o => { //sign out if (account != null) { await helper.SignOutAsync(account); account = null; CommonAttributes.account = account; ProjectResults.Clear(); SignInOutButtonText = "Sign In"; } else //sign in { account = await helper.SignInAsync(); if (account != null) { CommonAttributes.account = account; UserName = account.UserName; //Store the stuff in a static class MenuOptions = new HamburgerMenuOptionsFactory(account).MenuOptions; SignInOutButtonText = "Sign Out"; } } }); MenuOptions = new HamburgerMenuOptionsFactory(account).MenuOptions; }
public MainPageViewModel(IAuthenticationHelper _helper, IProjectAPI _projectAPI, INavigationService _service) { helper = _helper; service = _service; projectAPI = _projectAPI; initDummyCategories(); //pop up the login screen if user is not logged in //called only on startup SignInCommand = new RelayCommand(async a => { if (account == null) { SignInOutButtonText = "Sign In"; account = await helper.SignInAsync(); if (account != null) { CommonAttributes.account = account; UserName = account.UserName; GetRecentProjects(); SignInOutButtonText = "Sign Out"; MenuOptions = new HamburgerMenuOptionsFactory(account).MenuOptions; } } else { GetRecentProjects(); SignInOutButtonText = "Sign Out"; } }); SignInOutCommand = new RelayCommand(async o => { //sign out if (account != null) { await helper.SignOutAsync(account); account = null; CommonAttributes.account = account; Content.Clear(); SignInOutButtonText = "Sign In"; service.Navigate(typeof(LogInPage), null); } else //sign in { account = await helper.SignInAsync(); if (account != null) { //initDummyProjects(); GetRecentProjects(); CommonAttributes.account = account; UserName = account.UserName; //Store the stuff in a static class MenuOptions = new HamburgerMenuOptionsFactory(account).MenuOptions; SignInOutButtonText = "Sign Out"; } } }); RepopulateContentCommand = new RelayCommand(async(tabName) => { //Populate lists switch (tabName) { case "Recent": GetRecentProjects(); break; case "Categories": initDummyCategories(); break; } }); //pop up sign in page on startup SignInCommand.Execute(null); //Store the stuff in a static class MenuOptions = new HamburgerMenuOptionsFactory(account).MenuOptions; CommonAttributes.MenuOptions = MenuOptions; }
public LogInPageViewModel(IAuthenticationHelper _helper, INavigationService _service, IUserAPI _userAPI) { helper = _helper; service = _service; userAPI = _userAPI; //gets called when app starts InitCommand = new RelayCommand(async o => { account = await helper.GetAccountAsync(); if (account != null) { //check api if user exists var user = await userAPI.GetMyself(); //navigate to main page if (user != null) { CommonAttributes.account = account; service.Navigate(typeof(MainPage), null); } else { service.Navigate(typeof(RegisterPage), account); } } }); //gets called when log in button is pressed LogInCommand = new RelayCommand(async o => { account = await helper.GetAccountAsync(); //navigate to main page if (account == null) { //pop up sign in page account = await helper.SignInAsync(); //if sign in is successfull if (account != null) { CommonAttributes.account = account; //check api if user exists var user = await userAPI.GetMyself(); if (user == null) { service.Navigate(typeof(RegisterPage), account); } else { service.Navigate(typeof(MainPage), null); } } } else { CommonAttributes.account = account; //check api if user exists var user = await userAPI.GetMyself(); if (user == null) { service.Navigate(typeof(RegisterPage), account); } else { service.Navigate(typeof(MainPage), null); } } }); }