Example #1
0
        public async Task<bool> SignUpUser(SignUpViewModel objSignUpViewModel, IAuthenticationManager authenticationManager)
        {
            var newuser = new ApplicationUser()
            {
                //Id = objRegisterModel.UserName,
                UserName = objSignUpViewModel.UserName,
                Email = objSignUpViewModel.EmailAddress,
                Password = objSignUpViewModel.Password,
                SecurityQuestion = objSignUpViewModel.SecurityQuestion,
                SecurityAnswer = objSignUpViewModel.SecurityAnswer,
                 LastName = objSignUpViewModel.LastName,
                FirstName = objSignUpViewModel.FirstName,
                Cellphone = objSignUpViewModel.Cell

            };

            var result = await UserManager.CreateAsync(
               newuser, objSignUpViewModel.Password);

            if (result.Succeeded)
            {
                await SignInAsync(newuser, false, authenticationManager);
                return true;
            }
            return false;
        }
Example #2
0
        //[CaptchaMvc.Attributes.CaptchaVerify("Incorrect captcha text")]
        public async Task<ActionResult> SignUp(SignUpViewModel objSignUpViewModel, bool captchaValid)
        {
            PatientViewModel patient=new PatientViewModel();
            if (ModelState.IsValid)
            {
                var signUpbusiness = new SignUpBusiness();

                if (signUpbusiness.FindUser(objSignUpViewModel.UserName, AuthenticationManager))
                {
                    ModelState.AddModelError("", "User already exists");
                    return View(objSignUpViewModel);
                }

                var result = await signUpbusiness.SignUpUser(objSignUpViewModel, AuthenticationManager);

                patient.UserName = objSignUpViewModel.UserName;
                patient.IdentificationNumber = "";
                patient.FirstName = objSignUpViewModel.FirstName;
                patient.LastName = objSignUpViewModel.LastName;

                patient.Cellphone = objSignUpViewModel.Cell;
                patient.Email = objSignUpViewModel.EmailAddress;
                patient.Occupation = "";
                patient.SecurityQuestion = objSignUpViewModel.SecurityQuestion;
                patient.SecurityAnswer = objSignUpViewModel.SecurityAnswer;

                _client.Insert(patient);


                if (result)
                {
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", result.ToString());
                }
            }
            return View(objSignUpViewModel);
            }