private async Task DoLogin() { var loginResult = await _edsWebApiService.LoginAsync(Email, SecurePassword); if (loginResult != null) { IsLoggedIn = true; IsNotLoggedIn = false; _appSettingsService.GetSettings().Email = Email; } else { IsNotLoggedIn = true; } if ((loginResult != null) && StorePassword) { _appSettingsService.GetSettings().ProtectedPassword = PasswordEncryptionService.Protect(SecurePassword); } else { _appSettingsService.GetSettings().ProtectedPassword = string.Empty; } _appSettingsService.SaveSettings(); }
public LoginViewModel(IAppSettingsService appSettingsService, IEdsWebApiService edsWebApiService) { _appSettingsService = appSettingsService; _edsWebApiService = edsWebApiService; Email = _appSettingsService.GetSettings().Email; StorePassword = !string.IsNullOrEmpty(_appSettingsService.GetSettings().ProtectedPassword); SecurePassword = PasswordEncryptionService.UnProtectToSecureString(_appSettingsService.GetSettings().ProtectedPassword); _loginEnabled = this.WhenAnyValue( x => x.Email, x => x.SecurePassword, x => x.IsLoggedIn, (email, securePassword, isLoggedIn) => !isLoggedIn && !string.IsNullOrEmpty(email) && (securePassword.Length != 0)).ToProperty(this, x => x.LoginEnabled); LoginCommand = ReactiveCommand.CreateFromTask( async() => { await DoLogin(); }, this.WhenAnyValue(x => x.LoginEnabled)); LoginCommand.ThrownExceptions.Subscribe(ex => MessageBus.Current.SendMessage(ex)); }
protected async override void OnAppearing() { //get settings and intialize controls var settings = await settingsService.GetSettings(); swEnableListSharing.On = settings.EnableListSharing; swEnableNotifications.On = settings.EnableNotifications; //get current User and intialize controls var currentUser = await usersService.GetUser(settings.CurrentUserId); txtUserName.Text = currentUser.UserName; txtEmail.Text = currentUser.Email; base.OnAppearing(); }
protected async override void OnAppearing() { settings = await settingsService.GetSettings(); LoadBucketState(); //fill controls with currentBucket properties base.OnAppearing(); }
public async override void Init(object initData) { base.Init(initData); currentCocktail = initData as Cocktail; settings = await _settingsService.GetSettings(); await RefreshCocktail(); }
private async Task EnsureUserAndSettings() { var settings = await settingsService.GetSettings(); if (settings == null) { //create new user var newUser = new User { Id = Guid.Parse("00000000-0000-0000-0000-000000000001"), FirstName = "", LastName = "" }; await usersService.CreateUser(newUser); //create new settings var newSettings = new AppSettings { CurrentUserId = newUser.Id }; await settingsService.SaveSettings(newSettings); } else { var currentUser = await usersService.GetUser(settings.CurrentUserId); if (currentUser.FirstName != null) { NameUser = currentUser.FirstName; } } }
/// <summary> /// Callled whenever the page is navigated to. /// </summary> /// <param name="initData"></param> public async override void Init(object initData) { currentLocationGroup = initData as LocationGroup; var settings = await settingsService.GetSettings(); currentUser = await usersService.GetUserById(settings.CurrentUserId); await RefreshLocationGroup(); }
/// <summary> /// Called whenever the page is navigated to. /// </summary> /// <param name="initData"></param> public async override void Init(object initData) { base.Init(initData); currentBucket = initData as Bucket; settings = await settingsService.GetSettings(); await RefreshBucket(); }
/// <summary> /// Callled whenever the page is navigated to. /// </summary> /// <param name="initData"></param> public async override void Init(object initData) { base.Init(initData); currentBucket = initData as Bucket; var settings = await settingsService.GetSettings(); currentUser = await usersService.GetUserById(settings.CurrentUserId); await RefreshBucket(); }
private async Task RefreshLocationGroupList() { IsBusy = true; //get settings, because we need current user Id var settings = await settingsService.GetSettings(); //get all locationGrouplist for this user var locationGrouplist = await locationGroupsService.GetLocationGrouplistForUser(settings.CurrentUserId); //bind IEnumerable<LocationGroup> to the ListView's ItemSource LocationGrouplist = null; //Important! ensure the list is empty first to force refresh! LocationGrouplist = new ObservableCollection <LocationGroup>(locationGrouplist); IsBusy = false; }
private async Task RefreshBucketLists() { IsBusy = true; //get settings, because we need current user Id var settings = await settingsService.GetSettings(); try { //get all bucket lists for this user var buckets = await bucketsService.GetBucketListsForUser(settings.CurrentUserId); //bind IEnumerable<Bucket> to the ListView's ItemSource Buckets = null; //Important! ensure the list is empty first to force refresh! Buckets = new ObservableCollection<Bucket>(buckets.OrderBy(e => e.Title)); } catch(Exception ex) { await CoreMethods.DisplayAlert("Error", $"{ex.Message}", "Ok"); } finally { IsBusy = false; } }
public async override void Init(object initData) { base.Init(initData); var settings = await settingsService.GetSettings(); var currentUser = await usersService.GetUser(settings.CurrentUserId); FirstName = currentUser.FirstName; LastName = currentUser.LastName; Age = currentUser.Age; await RefreshCocktails(); }
private async Task RefreshBucketLists() { IsBusy = true; //get settings, because we need current user Id var settings = await settingsService.GetSettings(); //get all bucket lists for this user var buckets = await bucketListService.GetBucketListsForUser(settings.CurrentUserId); //bind IEnumerable<Bucket> to the ListView's ItemSource Buckets = null; //Important! ensure the list is empty first to force refresh! Buckets = new ObservableCollection <Bucket>(buckets); IsBusy = false; }
private async Task RefreshBucketLists() { busyIndicator.IsVisible = true; //get settings, because we need current user Id var settings = await settingsService.GetSettings(); //get all bucket lists for this user var buckets = await bucketsService.GetBucketListsForUser(settings.CurrentUserId); //bind IEnumerable<Bucket> to the ListView's ItemSource lvBucketLists.ItemsSource = buckets; busyIndicator.IsVisible = false; }
/// <summary> /// Callled whenever the page is navigated to. /// </summary> /// <param name="initData"></param> public async override void Init(object initData) { base.Init(initData); //get settings and intialize controls var settings = await settingsService.GetSettings(); EnableListSharing = settings.EnableListSharing; EnableNotifications = settings.EnableNotifications; //get current User and intialize controls var currentUser = await usersService.GetUser(settings.CurrentUserId); UserName = currentUser.UserName; Email = currentUser.Email; }
public async Task <IActionResult> GetSettings() { var roles = await _appSettingsService.GetSettings(); return(Ok(roles)); }