async void btnOneTapSignUp_Clicked(object sender, EventArgs args)
		{
			var query = from dictionary in ParseObject.GetQuery("Dictionary")
					where dictionary.Get<int>("dicType") == 1 && dictionary.Get<bool>("isAvailable")
				select dictionary;
			IEnumerable<ParseObject> results = await query.Limit(1).FindAsync();

			if (results == null || results.Count() <= 0) 
			{
				await DisplayAlert ("Sign Up Failed", "There's no available usernames in the pool.", "OK");
				return;
			}

			var dic = results.First();
//			// or using LINQ
//			var query = ParseObject.GetQuery("GameScore").WhereEqualTo("playerName", "Dan Stemkoski");
//			IEnumerable<ParseObject> results = await query.FindAsync();

			if (dic == null) 
			{
				await DisplayAlert ("Sign Up Failed", "There's no available usernames in the pool.", "OK");
				return;
			}
				
			string userName = dic.Get<string> ("dicValue");
			string password = "******";
			var user = new ParseUser()
			{
				Username = userName,
				Password = password
			};
			await user.SignUpAsync ();

			dic["isAvailable"] = false;
			await dic.SaveAsync ();

			await ParseUser.LogInAsync (userName, password);

			App.Database.DeleteAllLocalInfos ();

			LocalInfo localInfo = new LocalInfo ();
			localInfo.UserName = userName;
			localInfo.Passcode = password;
			localInfo.Active = true;
			App.Database.SaveLocalInfo (localInfo);

			lblTitle.Text = "Welcome " + userName;
			lblMessage.Text = "New user signed up: \n" + userName + "  --  " + password;
		}
Пример #2
0
 public int SaveLocalInfo(LocalInfo item)
 {
     lock (locker) {
         if (item.ID != 0) {
             database.Update(item);
             return item.ID;
         } else {
             return database.Insert(item);
         }
     }
 }