/// <summary> /// Constructeur /// </summary> public NewPatientViewModel() { _firstname = ""; _name = ""; _birthday = DateTime.Now; _dataAccessPatient = new DataAccess.Patient(); _status = "Hidden"; AddCommand = new RelayCommand(param => Add(), param => true); }
public async Task <ActionResult> Register(LoginRegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.RegisterViewModel.Email, Email = model.RegisterViewModel.Email, FirstName = model.RegisterViewModel.FirstName, LastName = model.RegisterViewModel.LastName, }; // Add the Address properties: var result = await UserManager.CreateAsync(user, model.RegisterViewModel.Password); if (result.Succeeded) { var IsPatient = ViewBag.IsPatient != null ? (bool)ViewBag.IsPatient : false; var requestUri = IsPatient ? "api/Patients" : "api/Doctors"; requestUri = "api/Patients";//testing var patient = new DataAccess.Patient(); patient.userId = user.Id; patient.lastName = user.LastName; patient.firstName = user.FirstName; patient.email = user.Email; var strContent = JsonConvert.SerializeObject(patient); var response = ApiConsumerHelper.PostData(requestUri, strContent); dynamic resultAdd = JsonConvert.DeserializeObject(response); var userAssignRole = new UserAssignRoleModel(); userAssignRole.UserId = user.Id;//"8466ba63-b903-4d0a-8633-ce399ed1b542";// userAssignRole.Role = "Patient"; strContent = JsonConvert.SerializeObject(userAssignRole); response = ApiConsumerHelper.PostData("api/Roles/AssignRole", strContent); resultAdd = JsonConvert.DeserializeObject(response); var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>"); ViewBag.Link = callbackUrl; return(View("DisplayEmail")); } AddErrors(result); } // If we got this far, something failed, redisplay form //return View("Login", model); return(View("Login", model)); }