/// <summary> /// Initializes a new instance of the <see cref="HACCP.Core.ViewStatusViewModel" /> class. /// </summary> /// <param name="page">Page.</param> public ViewStatusViewModel(IPage page) : base(page) { dataStore = new SQLiteDataStore(); AppVerison = DependencyService.Get <IInfoService>().GetAppVersion(); StoreName = GetStoreName(); }
/// <summary> /// Executes the log in command. /// </summary> /// <returns>The log in command.</returns> private async Task ExecuteLogInCommand() { var shouldShowSelectUser = false; if (IsBusy) { return; } IsBusy = true; LogInCommand.ChangeCanExecute(); try { if (IsLoggedIn) { var checkLogout = await ShowLogoutConfirm(); if (checkLogout) { HaccpAppSettings.SharedInstance.CurrentUserId = 0; } } else { shouldShowSelectUser = true; } if (shouldShowSelectUser) { IDataStore dataStore = new SQLiteDataStore(); var isUserExist = dataStore.CheckUsersExist(); if (isUserExist) { await Page.NavigateTo(PageEnum.SelectUser, true); } else { await Page.ShowAlert(HACCPUtil.GetResourceString("NoUsersFound"), HACCPUtil.GetResourceString("NousersfoundPleasetapUpdateUserListintheWirelessTasksmenu")); } } } catch (Exception ex) { Debug.WriteLine("Ooops! Something went wrong while login. Exception: {0}", ex); } finally { IsBusy = false; LogInCommand.ChangeCanExecute(); } }
/// <summary> /// Initializes a new instance of the <see cref="HACCP.Core.UsersViewModel" /> class. /// </summary> /// <param name="page">Page.</param> public UsersViewModel(IPage page) : base(page) { try { IDataStore dataStore = new SQLiteDataStore(); var userList = dataStore.GetUsers(); Users = new ObservableCollection <User>(userList); UsersGrouped = new ObservableCollection <Grouping <string, User> >(); Sort(); currentLoggedInUserID = HaccpAppSettings.SharedInstance.CurrentUserId; if (currentLoggedInUserID > 0) { LoggedUser = Users.SingleOrDefault(u => u.Id == currentLoggedInUserID); } } catch (Exception ex) { Debug.WriteLine("Error User : {0}", ex.Message); } }