/// <summary> /// Attempts to log the user in. /// </summary> /// <param name="parameter">The <see cref="SecureString"/> passed in from the view for the users password.</param> /// <returns></returns> public async Task Login(object parameter) { await RunCommand(() => this.LoginIsRunning, async() => { DatingAPIConnection api = new DatingAPIConnection(); _context.CurrentUser = await api.Login(Username, (parameter as IHavePassword).SecurePassword.Unsecure()); }); }
public async Task SaveProfile(object parameter) { await RunCommand(() => this.SaveIsRunning, async() => { try { DatingAPIConnection api = new DatingAPIConnection(); Profile profile = new Profile() { UserRefID = _context.CurrentUser.ID, FirstName = FirstName, LastName = LastName, Age = Age, Gender = Gender }; //If user doesnt have a profile create one. if (_context.CurrentUser.UserProfile == null) { profile = await api.CreateProfileAsync(profile); } //if user does have a profile update instead. else { profile.ID = _context.CurrentUser.UserProfile.ID; profile = await api.UpdateProfileAsync(profile); } //If success then change currentuser objects profile else dont. if (profile != null) { _context.CurrentUser.UserProfile = profile; } User test = _context.CurrentUser; } catch (Exception) { } }); }