Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. //EditUser
  2. private ListItemCollection LoadProfession()
  3. {
  4. var items = new ListItemCollection
  5. {
  6. new ListItem("Välj"),
  7. new ListItem("Läkare", "läkare"),
  8. new ListItem("Sjuksköterska", "sjuksköterska"),
  9. new ListItem("Övrig hälso- och sjukvårdspersonal", "övrig personal"),
  10. new ListItem("Annat", "annat")
  11. };
  12.  
  13. return items;
  14. }
  15.  
  16. private void LoadUserSettings()
  17. {
  18. EPiServerProfile profile = EPiServerProfile.Get(Page.User.Identity.Name);
  19.  
  20. txtEditName.Value = profile["RegisterUser.Name"] as string;
  21. txtEditAddress.Value = profile["RegisterUser.Address"] as string;
  22. txtEditPostalCode.Value = profile["RegisterUser.PostalCode"] as string;
  23. txtEditCity.Value = profile["RegisterUser.City"] as string;
  24. dropDownEditProfession.SelectedValue = profile["RegisterUser.Profession"] as string;
  25.  
  26. }
  27.  
  28. public void EditUser()
  29. {
  30. string newPassword = string.Empty;
  31.  
  32. if (!string.IsNullOrEmpty(txtPassword.Value) && !string.IsNullOrEmpty(txtConfirmPassword.Value))
  33. {
  34. if (txtPassword.Value == txtConfirmPassword.Value)
  35. {
  36. newPassword = txtPassword.Value;
  37. }
  38. else
  39. {
  40. editMessages.AddError("De båda fälten för lösenord måste överrensstämma");
  41. }
  42. }
  43.  
  44. EPiServerProfile profile = EPiServerProfile.Get(Page.User.Identity.Name);
  45. profile.SetPropertyValue("RegisterUser.AccountType", Request.Form["account-type"]);
  46. profile.SetPropertyValue("RegisterUser.Name", txtName.Value);
  47. profile.SetPropertyValue("RegisterUser.Address", txtAddress.Value);
  48. profile.SetPropertyValue("RegisterUser.PostalCode", txtPostalCode.Value);
  49. profile.SetPropertyValue("RegisterUser.City", txtCity.Value);
  50. profile.SetPropertyValue("RegisterUser.Profession", dropDownProfession.SelectedValue);
  51.  
  52. if (!string.IsNullOrEmpty(newPassword))
  53. {
  54. MembershipUser user = Membership.GetUser(Page.User.Identity.Name);
  55. user.ChangePassword(user.ResetPassword(), newPassword);
  56. }
  57.  
  58. editMessages.AddConfirmation("Ändringarna sparades");
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement