Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. // POST: /Account/Register
  2. [HttpPost]
  3. [AllowAnonymous]
  4. [ValidateAntiForgeryToken]
  5. public async Task<ActionResult> Register(RegisterViewModel model)
  6. {
  7. if (ModelState.IsValid)
  8. {
  9. var user = new ApplicationUser { UserName = model.email, Email = model.email };
  10. var result = await UserManager.CreateAsync(user, model.Password);
  11. if (result.Succeeded)
  12. {
  13. if (User.IsInRole("Manager"))
  14. {
  15. klant a = new klant();
  16. a.naam = model.naam;
  17. a.achternaam = model.achternaam;
  18. a.straatnaam = model.straatnaam;
  19. a.email = model.email;
  20. model.Password = model.Password;
  21. a.postcode = model.postcode;
  22. a.tussenvoegsel = model.tussenvoegsel;
  23. a.woonplaats = model.woonplaats;
  24.  
  25. medewerkers b = new medewerkers();
  26. b.medewerkernaam = model.medewerkernaam;
  27. b.medewerkerachternaam = model.medewerkerachternaam;
  28. b.winkelcode = model.winkelcode;
  29. entitie.klant.Add(a);
  30. entitie.medewerkers.Add(b);
  31. entitie.SaveChanges();
  32. }
  33. else
  34. {
  35. klant a = new klant();
  36. a.naam = model.naam;
  37. a.achternaam = model.achternaam;
  38. a.straatnaam = model.straatnaam;
  39. a.email = model.email;
  40. model.Password = model.Password;
  41. a.postcode = model.postcode;
  42. a.tussenvoegsel = model.tussenvoegsel;
  43. a.woonplaats = model.woonplaats;
  44.  
  45. entitie.klant.Add(a);
  46. entitie.SaveChanges();
  47. }
  48.  
  49.  
  50. // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
  51. // Send an email with this link
  52. // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
  53. // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
  54. // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
  55.  
  56. return RedirectToAction("Index", "Home");
  57. }
  58. AddErrors(result);
  59. }
  60.  
  61. // If we got this far, something failed, redisplay form
  62. return View(model);
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement