示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            this.usuario   = usuarioInput.Text;
            this.password  = passwordInput.Text;

            if (this.usuario.Length > 0 && this.password.Length > 0)
            {
                //TODO validate account with API
                RESTClient httpClient = new RESTClient("http://localhost:8080/tareas", httpVerb.GET);
                // -----
                string response = string.Empty;

                response = httpClient.makeRequest();
                Console.WriteLine(response);
                if (httpClient.errorRequest)
                {
                    Form errorResponseForm = new FormErrorResponse();
                    errorResponseForm.Show();
                }
                else
                {
                    this.Hide();
                    var tasksForm = new FormBuscadorTareas();
                    tasksForm.Closed += (s, args) => this.Close();
                    tasksForm.Show();
                }
            }
            else
            {
                Form errorInput = new FormErrorInputLogin();
                errorInput.Show();
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            this.usuario   = userInput.Text;
            this.password  = passwordInput.Text;

            if (this.usuario.Length > 0 && this.password.Length > 0)
            {
                RESTClient httpClient = new RESTClient("http://localhost:8080/signup", httpVerb.POST);

                string response = string.Empty;

                string body = "{\"username\":\"" + usuario + "\"," +
                              "\"password\":\"" + password + "\"}";

                response = httpClient.makeBodyRequest(body);
                Console.WriteLine(response);
                if (httpClient.errorRequest)
                {
                    Form errorResponseForm = new FormErrorResponse(response);
                    errorResponseForm.Show();
                }
                else
                {
                    this.Hide();
                    Usuario user      = JsonConvert.DeserializeObject <Usuario>(response);
                    var     tasksForm = new FormBuscadorTareas(user);
                    tasksForm.Closed += (s, args) => this.Close();
                    tasksForm.Show();
                }
            }
            else
            {
                Form errorInput = new FormErrorInput();
                errorInput.Show();
            }
        }