コード例 #1
0
        private async Task AuthenticateUser()
        {
            var email = emailBox.Text;
            var pass  = passwordBox.Text;

            var loginBody = new JObject();

            loginBody["email"]    = email;
            loginBody["password"] = pass;

            var response = await SolverApp.PostRequest("/api/auth/login", loginBody);

            if (response == null)
            {
                return;
            }

            SolverApp.SetJwt(response["auth_token"].ToString());
            SolverApp.SetEmail(response["email"].ToString());

            var mainWindow = new MainWindow();

            SolverApp.GetApp().AddWindow(mainWindow);
            mainWindow.ShowAll();

            SolverApp.GetApp().RemoveWindow(this);
            this.Hide();
        }
コード例 #2
0
        private async Task AutheticateSolver()
        {
            try {
                var email = emailBox.Text;
                var name  = nameBox.Text;
                var pass  = passBox.Text;
                var conf  = confBox.Text;

                var registerBody = new JObject();
                registerBody["email"]        = email;
                registerBody["username"]     = name;
                registerBody["password"]     = pass;
                registerBody["passwordConf"] = conf;
                registerBody["role"]         = "solver";

                var response = await SolverApp.PostRequest("/api/users/", registerBody);

                if (response == null)
                {
                    return;
                }

                var loginBody = new JObject();
                loginBody["email"]    = email;
                loginBody["password"] = pass;

                var loginResponse = await SolverApp.PostRequest("/api/auth/login", loginBody);

                if (loginResponse == null)
                {
                    return;
                }

                SolverApp.SetJwt(loginResponse["auth_token"].ToString());
                SolverApp.SetEmail(loginResponse["email"].ToString());

                var mainWindow = new MainWindow();
                SolverApp.GetApp().AddWindow(mainWindow);
                mainWindow.ShowAll();

                SolverApp.GetApp().RemoveWindow(this);
                this.Hide();
            } catch (Exception e) {
                Console.WriteLine(e);
            }
        }
コード例 #3
0
        private async Task SendQuestion()
        {
            try {
                Console.WriteLine("coiso");
                var endpoint    = $"http://localhost:3000/api/solver/{issueID}/question";
                var requestBody = new JObject();
                requestBody["question"]   = questionText.Buffer.Text;
                requestBody["department"] = departmentEntry.Text;

                var response = await SolverApp.PostRequest(endpoint, requestBody);

                if (response["question"] == null)
                {
                    return;
                }

                var responseQuestion = response["question"];

                issueWindow.questions[responseQuestion["question"].ToString()] = new Question()
                {
                    Text       = responseQuestion["question"].ToString(),
                    Department = responseQuestion["department"].ToString(),
                    State      = responseQuestion["state"].ToString(),
                    Date       = responseQuestion["createdAt"].ToString()
                };

                var questionRow = new ListBoxRow();
                questionRow.Add(new Label {
                    Text = responseQuestion["question"].ToString(), Expand = true
                });
                issueWindow.questionsList.Add(questionRow);
                questionRow.ShowAll();

                issueWindow.Sensitive = true;
                SolverApp.GetApp().RemoveWindow(this);
                this.Dispose();
            } catch (Exception e) {
                Console.WriteLine(e.ToString());
            }
        }