Beispiel #1
0
        private void buttSignIn_Click(object sender, EventArgs e)
        {
            string           address    = "https://myprjmera.herokuapp.com/api/Conections";
            List <Conection> conections = new List <Conection>();
            Conection        conection  = new Conection();

            conections = conection.Http_GET(address);
            bool nam = false;

            for (int i = 0; i < conections.Count; i++)
            {
                if ((conections[i].Name == tbName.Text) && (conections[i].Password == tbPass.Text))
                {
                    conection = conections[i];
                    LocWork locWork = new LocWork(this, conection, address); //создам новую форму
                    locWork.Show();
                    this.Hide();
                    nam = true;
                }
            }
            if (nam == false)
            {
                MessageBox.Show("Invalid user name or password.");
            }
        }
Beispiel #2
0
        private void butSignUp_Click(object sender, EventArgs e)
        {
            if (tbName.Text == "")
            {
                MessageBox.Show("Invalid user name.");
                return;
            }
            string           address    = "https://myprjmera.herokuapp.com/api/Conections";
            Conection        conection  = new Conection(tbName.Text, tbPass.Text);
            List <Conection> conections = new List <Conection>();

            conections = conection.Http_GET(address);
            foreach (var item in conections)
            {
                if (item.Name == conection.Name)
                {
                    MessageBox.Show("This name already exists.");
                    return;
                }
            }
            string data = JsonSerializer.Serialize <Conection>(conection);
            string res  = conection.Http_post(address, data);

            if (res.Length > 0)
            {
                MessageBox.Show("Account created");
            }
        }