Пример #1
0
        public async Task <ServiceResponse> ChangePassword(LoginRequest lData)
        {
            ServiceResponse sResponse = new ServiceResponse();

            try
            {
                var users = await _usersData.FindByUsernameAsync(lData.userName);

                if (users.Count > 0)
                {
                    var hashPassword = BCrypt.Net.BCrypt.HashPassword(lData.password);

                    var changePwd = _usersData.ChangePassword(lData.userName, hashPassword);
                    if (changePwd.msgRespone == true)
                    {
                        sResponse.Status  = "true";
                        sResponse.Message = changePwd.msg;
                    }
                    else
                    {
                        sResponse.Status  = "false";
                        sResponse.Message = changePwd.msg;
                    }
                }
                else
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Username does not exist";
                }
                return(sResponse);
            }
            catch (Exception e)
            {
                sResponse.Status  = "false";
                sResponse.Message = e.Message;
            }
            return(sResponse);
        }