public async Task <IHttpActionResult> Register(RegisterBindingModel model)
        {
            DBUpdates dbupdate = new DBUpdates();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var user = new ApplicationUser()
                {
                    UserName = model.Email, Email = model.Email
                };

                IdentityResult result = await UserManager.CreateAsync(user, model.Password);

                dbupdate.updateSecurityQuestion(model.Email, model.SecurityQuestion, model.SecurityAnswer);

                if (!result.Succeeded)
                {
                    return(GetErrorResult(result));
                }

                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError());
            }
        }
        public string GetSecurityQuestion([FromUri] string useremail)
        {
            DBUpdates dbupdates        = new DBUpdates();
            var       securityquestion = dbupdates.GetSecurityQuestion(useremail);

            if (securityquestion != null && securityquestion != "")
            {
                return(securityquestion);
            }
            else
            {
                return(null);
            }
        }
        public async Task <IHttpActionResult> ResetPassword([FromBody] ResetPasswordBindingModel model)
        {
            DBUpdates dbupdates = new DBUpdates();
            Response  response  = new Response();

            if (model.SecurityAnswer != null && model.SecurityAnswer != "")
            {
                response = dbupdates.IsSecurityValid(model.Email, model.SecurityAnswer);

                if (response.isSuccess)
                {
                    if (model.Email != null)
                    {
                        var user  = UserManager.FindByEmail(model.Email);
                        var token = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                        var result = await UserManager.ResetPasswordAsync(user.Id, token, model.NewPassword);

                        if (!result.Succeeded)
                        {
                            return(GetErrorResult(result));
                        }

                        return(Ok());
                    }
                    else
                    {
                        response.ErrorList = new List <string> {
                            "Email Is Blank or Incorrect. Please Enter Correct Email."
                        };
                        return(GetErrorResult(response));
                    }
                }
                else
                {
                    response.ErrorList = new List <string> {
                        "Answer for Security Question is Incorrect. Please Enter Correct Security Question Answer."
                    };
                    return(GetErrorResult(response));
                }
            }
            else
            {
                response.ErrorList = new List <string> {
                    "Answer for Security Question is Incorrect. Please Enter Correct Security Question Answer."
                };
                return(GetErrorResult(response));
            }
        }
        public IHttpActionResult Register(RegisterModel registermodel)
        {
            DBUpdates da = new DBUpdates();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //var response = da.CreateUser(registermodel.Email, registermodel.Password);

            //if (!response.isSuccess)
            //{
            //    return GetErrorResult(response);
            //}

            return(Ok());
        }