public async Task <Object> ChangePasswordAsync([FromBody] UpdateApplicationUserRequest request)
        {
            try
            {
                var result = await _applicationUserService.ChangePassword(request);

                return(Ok(new { successMessage = "Password changed", newPassword = result }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { errorMessage = ex.Message }));
            }
        }
        public async Task <Object> SingInUserAsync([FromBody] UpdateApplicationUserRequest request)
        {
            try
            {
                //request = new UpdateApplicationUserRequest
                //{
                //    NewPassword = "******",
                //    UserEmail = "*****@*****.**",
                //    UserId = "d2fb5abe-d37e-459b-9be4-24228b06fd8c",
                //    UserName = "******",
                //    UserPassword = "******"

                //};

                var signInResultModel = await _applicationUserService.SignInUserAsync(request);

                if (signInResultModel is null)
                {
                    return(BadRequest(new { errorMessage = "Incorrect password or username" }));
                }

                var tokenDescriptor = new SecurityTokenDescriptor
                {
                    Subject = new ClaimsIdentity(new Claim[]
                    {
                        new Claim(ClaimTypes.Role, signInResultModel.ApplicationUserRole),
                        new Claim(ClaimTypes.UserData, signInResultModel.ApplicationUserId)
                    }),
                    Expires            = DateTime.UtcNow.AddMinutes(30),
                    SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_appConfig["ApplicationSettings:JWT"].ToString())), SecurityAlgorithms.HmacSha256Signature)
                };

                var tokenHandler  = new JwtSecurityTokenHandler();
                var securityToken = tokenHandler.CreateToken(tokenDescriptor);
                var token         = tokenHandler.WriteToken(securityToken);

                return(Ok(new { successMessage = "Sign in success!", token, userName = signInResultModel.ApplicationUserName, userId = signInResultModel.ApplicationUserId, userPassword = request.UserPassword, userRole = signInResultModel.ApplicationUserRole, userEmail = signInResultModel.ApplicationUserEmail }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { errorMessage = ex.Message }));
            }
        }
        public async Task <Object> SignUpUserAsync([FromBody] UpdateApplicationUserRequest request)
        {
            try
            {
                request.UserRole = _appConfig["ApplicationSettings:userRoleName"];

                var signUpResultModel = await _applicationUserService.CreateApplicationUserAsync(request);

                if (signUpResultModel is null)
                {
                    return(BadRequest(new { message = "This username already taken" }));
                }

                return(Ok(signUpResultModel));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }