Ejemplo n.º 1
0
        public async Task <IActionResult> AddPatient(AddPatientViewModel input)
        {
            string password = "******";
            var    roleName = "Patient";

            var user = administratorService.CreatePatient(input.FirstName, input.LastName, input.Email, input.BirthDate, input.Address, input.Town, input.PhoneNumber, input.Email);

            var patient = await userManager.CreateAsync(user, password);

            if (!patient.Succeeded)
            {
                //var token = await userManager.GenerateEmailConfirmationTokenAsync(createPatient);
                //var confirmationLink = Url.Action("ConfirmEmail", "Account",
                //    new { createPatient.Id, token = token }, Request.Scheme);
                //logger.Log(LogLevel.Warning, confirmationLink);
            }

            var result = await userManager.AddToRoleAsync(user, roleName);

            if (!result.Succeeded)
            {
                //  TODO: handle
            }

            return(Redirect("AllPatients"));
        }