本文整理汇总了C#中Parse.ParseUser.SaveAsync方法的典型用法代码示例。如果您正苦于以下问题:C# ParseUser.SaveAsync方法的具体用法?C# ParseUser.SaveAsync怎么用?C# ParseUser.SaveAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse.ParseUser
的用法示例。
在下文中一共展示了ParseUser.SaveAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateUser
public async Task<ActionResult> CreateUser(FormCollection form)
{
try
{
var user = new ParseUser()
{
Username = form["username"],
Password = form["password"],
Email = form["email"]
};
user["firstName"] = form["firstName"].ToString();
user["lastName"] = form["lastName"].ToString();
user["phoneNumber"] = form["phoneNumber"].ToString();
user["address"] = form["address"].ToString();
user["birthday"] = DateTime.Parse(form["birthday"].ToString());
user["gender"] = bool.Parse(form["gender"]);
user["role"] = form["role"].ToString();
await user.SaveAsync();
return RedirectToAction("UserList");
}
catch (ParseException pe)
{
ViewBag.Error = "Error input form " + pe.Message + " ! Please retry";
return View();
}
}
示例2: SignUp
private async Task SignUp(int registrationTestScore)
{
ParseRole adminRole = await Constants.Role.Admin();
var user = new ParseUser()
{
Username = MyRegistrationInfo.Email.ToLower(),
Password = MyRegistrationInfo.Password,
Email = MyRegistrationInfo.Email.ToLower(),
};
await user.SignUpAsync();
ParseRole tutorRole = await Constants.Role.Tutor();
tutorRole.Users.Add(user);
await tutorRole.SaveAsync();
PrivateTutorData privateTutorData = new PrivateTutorData();
privateTutorData.BaseUserId = user.ObjectId;
privateTutorData.Students = new List<PublicUserData>();
privateTutorData.RequestsFromStudents = new List<PublicUserData>();
privateTutorData.Blocked = new List<ParseUser>();
privateTutorData.ACL = new ParseACL(user);
privateTutorData.ACL.SetRoleReadAccess(adminRole, true);
privateTutorData.ACL.SetRoleWriteAccess(adminRole, true);
await privateTutorData.SaveAsync();
Tutor tutor = new Tutor();
tutor.NumQuestionsCreated = 0;
tutor.NumQuestionsReviewed = 0;
tutor.BaseUserId = user.ObjectId;
tutor.Biography = "";
tutor.PrivateTutorData = privateTutorData;
tutor.ACL = new ParseACL();
tutor.ACL.PublicReadAccess = true;
tutor.ACL.PublicWriteAccess = false;
tutor.ACL.SetWriteAccess(user, true);
tutor.ACL.SetRoleReadAccess(adminRole, true);
tutor.ACL.SetRoleWriteAccess(adminRole, true);
await tutor.SaveAsync();
PublicUserData publicUserData = new PublicUserData();
publicUserData.UserType = Constants.UserType.TUTOR;
publicUserData.DisplayName = MyRegistrationInfo.FirstName.Trim() + " " + MyRegistrationInfo.LastName.Trim();
publicUserData.SearchableDisplayName = MyRegistrationInfo.FirstName.Trim().ToLower() + MyRegistrationInfo.LastName.Trim().ToLower();
publicUserData.BaseUserId = user.ObjectId;
publicUserData.Tutor = tutor;
string path = HttpContext.Current.Server.MapPath("~/Images/default_prof_pic.png");
byte[] pic = File.ReadAllBytes(path);
publicUserData.ProfilePic = new ParseFile("default-profile-pic", pic);
publicUserData.ACL = new ParseACL();
publicUserData.ACL.PublicReadAccess = true;
publicUserData.ACL.PublicWriteAccess = false;
publicUserData.ACL.SetWriteAccess(user, true);
publicUserData.ACL.SetRoleReadAccess(adminRole, true);
publicUserData.ACL.SetRoleWriteAccess(adminRole, true);
await publicUserData.SaveAsync();
user["registrationTestScore"] = registrationTestScore;
user.ACL = new ParseACL(user);
user.ACL.SetRoleReadAccess(adminRole, true);
user["publicUserData"] = publicUserData;
//user.phoneNumber = tbPhoneNumber.Text;
//user.zipCode = tbZipCode.Text;
//user.address = tbStreetAddress.Text;
//user.address2 = tbAddress2.Text;
//user.city = tbCity.Text;
//user.state = ddState.SelectedValue;
await user.SaveAsync();
}
示例3: register
private async void register(object sender, RoutedEventArgs e)
{
string name_c = name.Text;
string mail = email.Text;
string fecha = Fecha_Nacimiento.Date.Day + "/" + Fecha_Nacimiento.Date.Month + "/" + Fecha_Nacimiento.Date.Year;
int s = sex.SelectedIndex;
string sexo="";
switch (s)
{
case 0:
sexo = "Hombre";
break;
case 1:
sexo = "Mujer";
break;
}
string userr = user.Text;
string passs = pass.Password;
string re_passs = re_pass.Password;
int cont_error = 0;
if (name_c.Equals("") || userr.Equals("") || passs.Equals("") || re_passs.Equals("") || mail.Equals(""))
{
Errors.Text = "Por favor llene todos los campos.";
Errors.Visibility = Visibility.Visible;
var margin = panel.Margin;
margin.Top = -17;
panel.Margin = margin;
cont_error = 1;
}
if (!passs.Equals(re_passs))
{
Errors.Text = "Las contraseñas deben conicidir.";
Errors.Visibility = Visibility.Visible;
var margin = panel.Margin;
margin.Top = -17;
panel.Margin = margin;
cont_error = 1;
}
if (cont_error == 0)
{
try
{
PrgRing.Visibility = Visibility.Visible;
panel.Visibility = Visibility.Collapsed;
if (photo == null)
{
var packageLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
var assetsFolder = await packageLocation.GetFolderAsync("Assets");
if (sexo.Equals("Mujer")){
photo = await assetsFolder.GetFileAsync("mujer.jpg");
}
else {
photo = await assetsFolder.GetFileAsync("hombre.jpg");
}
}
var bytes = await GetBtyeFromFile(photo);
ParseFile parseFile = new ParseFile(userr + ".jpg", bytes, "image/jpeg");
ParseUser user = new ParseUser()
{
Username = userr,
Password = passs,
Email = mail
};
// other fields can be set just like with ParseObject
user["name"] = name_c;
user["sex"] = sexo;
user["b_date"] = fecha;
user.Add("photo", null);
await user.SignUpAsync();
PrgRing.Visibility = Visibility.Collapsed;
user["photo"] = parseFile;
await user.SaveAsync();
await ParseUser.LogInAsync(userr, passs);
Accept.Visibility = Visibility.Visible;
await Task.Delay(2000);
Frame rootFrame = Window.Current.Content as Frame;
rootFrame.Navigate(typeof(MainPage));
}
catch (Exception ex)
{
PrgRing.Visibility = Visibility.Collapsed;
panel.Visibility = Visibility.Visible;
string error = ex.Message;
if (error.Contains("username"))
{
Errors.Text = "El usuario "+userr+" ya se encuentra registrado.";
Errors.Visibility = Visibility.Visible;
var margin = panel.Margin;
margin.Top = -17;
panel.Margin = margin;
//.........这里部分代码省略.........
示例4: registerUserAsync
IEnumerator registerUserAsync(string username)
{
ParseUser user = new ParseUser()
{
Username = username,
Password = username
};
foreach (UserValues.Value val in userValues.coreValues.Concat(userValues.customValues))
{
user[val.name] = null;
if (val.isList)
{
user[val.name] = new List<object>();
} else
{
if (val.type == UserValues.FIELD_TYPE.TYPE_boolean)
{
user[val.name] = false;
}
if (val.type == UserValues.FIELD_TYPE.TYPE_String)
{
user[val.name] = "";
if (val.inputField != null)
{
user[val.name] = val.inputField.text;
}
}
if (val.type == UserValues.FIELD_TYPE.TYPE_Integer)
{
user[val.name] = 0;
}
}
}
user[UserValues.ACTIVE] = true;
Task signUpTask = user.SignUpAsync();
signUpTask.ContinueWith(t =>
{
Debug.Log("success register user? " + !t.IsFaulted );
});
while (!signUpTask.IsCompleted) yield return null;
ParseObject timeTable = new ParseObject("Timetable");
timeTable["user"] = user;
timeTable[UserValues.NICK] = userNickInput.GetComponent<InputField>().text;
foreach (string time in times)
{
timeTable[time] = false;
}
Task saveTimetableTask = timeTable.SaveAsync();
saveTimetableTask.ContinueWith(t =>
{
Debug.Log("success save user in time table? " + !t.IsFaulted);
});
while (!saveTimetableTask.IsCompleted) yield return null;
ParseUser.CurrentUser[UserValues.TIMETABLE] = timeTable;
Task saveUserInTimeTable = ParseUser.CurrentUser.SaveAsync();
saveUserInTimeTable.ContinueWith(t =>
{
Debug.Log("success save time table in user? " + !t.IsFaulted);
});
while (!saveUserInTimeTable.IsCompleted) yield return null;
user[UserValues.LAST_LOGIN] = DateTime.Now;
user.SaveAsync();
ParseInstallation.CurrentInstallation["user"] = ParseUser.CurrentUser;
Task saveUserInInstallation = ParseInstallation.CurrentInstallation.SaveAsync();
saveUserInInstallation.ContinueWith(t =>
{
Debug.Log("success save user in installation? " + !t.IsFaulted);
});
while (!saveUserInInstallation.IsCompleted) yield return null;
}
示例5: conversationAdded
private Task conversationAdded(ParseUser user, ParseUser partner)
{
Debug.Log("add conversation ");
List<ParseUser> partners = partnerList;
//getUserPartners(user);
if (!listContainsPartner(partners,partner))
{
Debug.Log("added partner");
partners.Add(partner);
user[UserValues.PARTNERS] = partners;
return user.SaveAsync();
}
return null;
}
示例6: SendLocations
/// <summary>
/// Send the unsent locations to the server.
/// </summary>
/// <param name="user">the user whose location data is to be sent</param>
/// <returns>true if successful</returns>
public async Task<bool> SendLocations(ParseUser user)
{
Queue<GeoPosition<GeoCoordinate>> temp = new Queue<GeoPosition<GeoCoordinate>>();
if (QueueSize() == 0)
return true;
try
{
await user.FetchIfNeededAsync();
while (QueueSize() > 0)
{
GeoPosition<GeoCoordinate> last = Dequeue();
temp.Enqueue(last);
Utilities.SaveLocationToParseUser(user, last);
}
await user.SaveAsync();
}
catch (Exception e)
{
Debug.WriteLine("Failed to send the unsent locations");
Debug.WriteLine(e.ToString());
while (temp.Count > 0)
{
Enqueue(temp.Dequeue());
}
Save();
return false;
}
Save();
return true;
}