public void FaceBookLogin() { GetMethods.GetUserId(email, (id) => { if (id != "0") // The user exits in the data base // Verify if an Update is necessary. { UpdateMethods.UpdateUsersDatabase(id, userName, age, AppManeger.instance.userGender.ToString(), (result) => { Debug.Log(string.Format("Update {0}", result)); }); string fileName = string.Format("Prefs_{0}", AppManeger.instance.userID); //GetMethods.GetUserPrefs(id, (prefsResult) => {PrefsResult(prefsResult);}); // Check if the user are in the Prefs Database if (SaveLoadData.FileExits(fileName)) // If exit { SaveLoadData.Load(fileName, SaveLoadData.DataType.UserPrefs); // load from device GoToCheersPanel(); // Means the user has everyting setted; } else { GetMethods.GetUserPrefs(id, (prefsResult) => { PrefsResult(prefsResult); }); // Check if the user are in the Prefs Database } } else // User don't exit in the data base { PostMethods.InsertUserIntoUsersDatabase(userName, age, email, gender, (result) => { InsertUserResult(result); }); } }); }
void InsertUserResult(string result) { if (result == "Success" || result == "success") // Finish to insert user into data base { Debug.Log(string.Format("Users was {0} insert into users database", result)); GetMethods.GetUserId(email, (id) => { if (id != "0") // The user exits in the data base { AppManeger.instance.userID = id; GetMethods.GetUserPrefs(id, (prefsResult) => { PrefsResult(prefsResult); }); // Check if the user are in the Prefs Database } }); } else { Debug.Log(result); } }