Advertisement
Guest User

Untitled

a guest
Jun 7th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. var newPatients = new List<PatientModel>();
  2.  
  3. foreach(ApplicationUser userPatient in userPatients)
  4. {
  5. newPatients.Add(new PatientModel { UserId = userPatient.Id });
  6. }
  7.  
  8. var patientCards = new PatientCardModel[]
  9. {
  10. new PatientCardModel
  11. {
  12. Date = "20/07/2017",
  13. PatientId = userPatients[0].Id.ToString(),
  14. ClerkId = userClerk.Id[0].ToString()
  15. },
  16. };
  17.  
  18.  
  19. string patientPassword = "H@sl01";
  20.  
  21. foreach (ApplicationUser userPatient in userPatients)
  22. {
  23. if (!context.ApplicationUser.Any(o => o.UserName == userPatient.UserName))
  24. {
  25. var residence = new ResidenceModel
  26. {
  27. Country = "Polska",
  28. Street = Streets[random.Next(0,Streets.Length)].ToString(),
  29. City = Towns[random.Next(0,Towns.Length)].ToString(),
  30. PostalCode = random.Next(10, 34).ToString()+ "-" +random.Next(100, 456).ToString(),
  31. BuildingNum = random.Next(1, 400).ToString(),
  32. FlatNum = random.Next(1, 120).ToString()
  33. };
  34.  
  35. context.ResidenceModel.Add(residence);
  36. context.SaveChanges();
  37.  
  38. var success = await userManager.CreateAsync(userPatient, patientPassword);
  39. if (success.Succeeded)
  40. {
  41. await userManager.AddToRoleAsync(userPatient, "Patient");
  42. }
  43. }
  44. }
  45.  
  46. if (!context.ApplicationUser.Any(o => o.UserName == userPatients[0].UserName))
  47. {
  48. foreach (PatientModel patient in newPatients)
  49. {
  50. context.PatientModel.Add(patient);
  51. context.SaveChanges();
  52. }
  53. }
  54.  
  55. if (!context.ApplicationUser.Any(o => o.UserName == userPatients[0].UserName))
  56. {
  57. foreach (PatientCardModel patientCard in patientCards)
  58. {
  59. context.PatientCardModel.Add(patientCard);
  60. context.SaveChanges();
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement