Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. // Settings
  2. [AllowAnonymous]
  3. public ActionResult Settings()
  4. {
  5. return View();
  6. }
  7.  
  8.  
  9.  
  10. [HttpPost]
  11. [AllowAnonymous]
  12. [ValidateAntiForgeryToken]
  13. public ActionResult Settings(RegisterViewModel model)
  14. {
  15. if (!ModelState.IsValid)
  16. {
  17. ViewBag.Msg = "Nieprawidłowe dane";
  18. return View();
  19. }
  20. else
  21. {
  22. ModelState.Clear();
  23. }
  24.  
  25.  
  26. try
  27. {
  28. var currentUserId = System.Web.HttpContext.Current.Session["CurrentUser"] as string ?? "unauthorized";
  29. var repo = new Repository<UserProfile>(new ProjectDataBase());
  30. var user = new DomainModel.UserProfile()
  31. {
  32. FirstName = model.FirstName,
  33. LastName = model.LastName,
  34. //BirthDate = model.BirthDate,
  35. Sex = model.Sex,
  36. City = model.City,
  37. MaritalStatus = model.MaritalStatus,
  38. Password = model.Password,
  39. LoginEmail = model.Email
  40.  
  41. };
  42.  
  43. if (currentUserId != "unauthorized")
  44. {
  45. repo.Edit(user);
  46. ViewBag.Msg = "Zmiany zostały zapisane";
  47. return View();
  48. }
  49.  
  50. ViewBag.Msg = "Użytkownik nie zalogowany";
  51. return View();
  52. }
  53. catch
  54. {
  55. ViewBag.Msg = "Błąd";
  56. }
  57. return View();
  58.  
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement