public SecQuestion getSecQuestion(int userId)
        {
            SecQuestion     secQuestion      = null;
            string          connectionString = config.GetConnectionString("DefaultConnection");
            MySqlConnection conn             = new MySqlConnection(connectionString);
            MySqlCommand    mySqlCommand     = new MySqlCommand();

            try
            {
                conn.Open();
                mySqlCommand.Connection  = conn;
                mySqlCommand.CommandText = "get_sec_question";
                mySqlCommand.CommandType = CommandType.StoredProcedure;
                mySqlCommand.Parameters.Add(new MySqlParameter("_user_id", userId));
                MySqlDataReader reader = mySqlCommand.ExecuteReader();
                while (reader.Read())
                {
                    secQuestion = getSecQuestionFromReader(reader);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            return(secQuestion);
        }
Exemplo n.º 2
0
        private async void checkExistingUsername()  //sees if username exists in database already
        {
            try
            {
                User completeUser = await getUserFromUsername(entryUsername.Text);

                if (completeUser.userId != 0)
                {
                    secQuestion = await getSecurityQuestion(completeUser.userId);

                    lblSecQuestion.Text = secQuestion.question;
                    isActivitySpinnerShowing(false);
                    isEnterSecQuestionLayoutShowing(true);
                    user = completeUser;
                }
                else
                {
                    isActivitySpinnerShowing(false);
                    isEnterUsernameLayoutShowing(true);
                    entryUsername.Text = "";
                    await DisplayAlert("Invalid Username", "There is no account associated with this username.", "Okay");
                }
            }
            catch (Exception ex)
            {
                isActivitySpinnerShowing(false);
                isEnterUsernameLayoutShowing(true);
                entryUsername.Text = "";
                await DisplayAlert("Error", "Error occurred.", "Okay");

                Debug.WriteLine(ex.Message);
            }
        }
Exemplo n.º 3
0
        private async void createSecurityQuestion()  //creates security question object, sends to web api to be created in database
        {
            SecQuestion secQuestion = new SecQuestion(user.userId, entrySecQuestion.Text, entrySecQuestionAnswer.Text);

            try
            {
                bool flag = await secQuestionController.createModel(secQuestion);

                if (flag)
                {
                    isActivitySpinnerShowing(false);
                    await DisplayAlert("Message", "Security Question Created Successfully!", "Okay");

                    App.Current.MainPage = new LoginPage();
                }
                else
                {
                    isActivitySpinnerShowing(false);
                    await DisplayAlert("Message", "Error Occurred.", "Okay");
                }
            }catch (Exception ex)
            {
                isActivitySpinnerShowing(false);
                isSecQuestionLayoutShowing(true);
                await DisplayAlert("Message", "Error Occured!", "Okay");

                Debug.WriteLine(ex.Message);
            }
        }
Exemplo n.º 4
0
        public void Init()
        {
            BackgroundColor          = Constants.backgroundColor;
            btnBackToLogin.TextColor = Constants.logoColor;

            userController        = new UserController();
            secQuestionController = new SecQuestionController();
            user        = new User();
            secQuestion = new SecQuestion();
        }
        private SecQuestion getSecQuestionFromReader(MySqlDataReader reader)
        {
            SecQuestion secQuestion = new SecQuestion();

            secQuestion.queId    = Int32.Parse(reader["que_id"].ToString());
            secQuestion.userId   = Int32.Parse(reader["user_id"].ToString());
            secQuestion.question = reader["question"].ToString();
            secQuestion.answer   = reader["answer"].ToString();
            return(secQuestion);
        }
        private JsonResult saveSecQuestion(SecQuestion secQuestion, string command)
        {
            Response response = new Response();
            SecQuestionDataHandler secQuestionDataHandler = new SecQuestionDataHandler(config);

            secQuestionDataHandler.queId    = secQuestion.queId;
            secQuestionDataHandler.userId   = secQuestion.userId;
            secQuestionDataHandler.question = secQuestion.question;
            secQuestionDataHandler.answer   = secQuestion.answer;
            if (command.Equals("create"))
            {
                response.status = secQuestionDataHandler.createSecQuestion();
            }
            return(Json(response));
        }
        public JsonResult getSecQuestion(int userId)
        {
            Response response = new Response();
            SecQuestionDataHandler secQuestionDataHandler = new SecQuestionDataHandler(config);

            try
            {
                SecQuestion secQuestion = secQuestionDataHandler.getSecQuestion(userId);
                response.data   = JsonConvert.SerializeObject(secQuestion);
                response.status = true;
            }
            catch (Exception ex)
            {
                response.status  = false;
                response.message = ex.Message;
            }
            return(Json(response));
        }
Exemplo n.º 8
0
 public JsonResult createSecQuestion(SecQuestion secQuestion)
 {
     throw new NotImplementedException();
 }
 public JsonResult createSecQuestion([FromBody] SecQuestion secQuestion)
 {
     return(saveSecQuestion(secQuestion, "create"));
 }