// SAVE private void SaveButtonOnClick(object sender, EventArgs e) { if (userModel == null) { userModel = new UserModel(); } userModel.Username = username.Text; userModel.Password = password.Text; userModel.FirstName = firstName.Text; userModel.LastName = lastName.Text; userModel.IsAdmin = admin.Checked; client.GetAllAsync(); client.GetAllUsersCompleted += CheckUsernameCompleted; if (userCheck == null) { client.SaveAsync(userModel); client.SaveCompleted += SaveUserCompleted; } else { RunOnUiThread(() => errors.Text = "Username already exists!"); } }
// REGISTER private void RegisterButtonOnClick(object sender, EventArgs e) { if (string.IsNullOrEmpty(username.Text) && string.IsNullOrEmpty(password.Text)) { result.Text = "Username and password cannot be null!"; } else if (string.IsNullOrEmpty(username.Text)) { result.Text = "Username cannot be null!"; } else if (string.IsNullOrEmpty(password.Text)) { result.Text = "Password cannot be null!"; } else { client.GetAllAsync(); client.GetAllUsersCompleted += CheckUsername; if (userCheck == null) { UserModel user = new UserModel { ID = 0, Username = username.Text, Password = password.Text }; client.SaveAsync(user); client.SaveCompleted += RegisterCompleted; } else { RunOnUiThread(() => result.Text = "Username already exists!"); } } }