Пример #1
0
 private void buttonRegister_Click(object sender, EventArgs e)
 {
     if (txtUsername.Text != null && txtPassword.Text != null)
     {
         HttpClient          client = new HttpClient();
         string              pw     = EncryptionDecryption.ComputeSha256Hash(txtPassword.Text);
         var                 uri    = new Uri(string.Format("https://apupay.azurewebsites.net/api/Shop?username="******"&password="******"application/json"));
         var content = new StringContent(String.Empty, Encoding.UTF8, "application/json");
         response = client.PostAsync(uri, content).Result;
         if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
         {
             MessageBox.Show("Registered Successfully");
             adminMenu.Show();
             this.Close();
         }
         else
         {
             MessageBox.Show("Rejected");
             response.Dispose();
             client.Dispose();
             txtUsername.Clear();
             txtPassword.Clear();
         }
     }
     else
     {
         MessageBox.Show("Please Fill Up all Details");
     }
 }
Пример #2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            string     type   = "Admin";
            string     pw     = EncryptionDecryption.ComputeSha256Hash(userPw.Text);
            HttpClient client = new HttpClient();
            var        uri    = new Uri(string.Format("http://apupay.azurewebsites.net/api/Login?username="******"&password="******"&type=" + type));

            HttpResponseMessage response;

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            response = client.GetAsync(uri).Result;
            if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
            {
                AdminMenu admin = new AdminMenu
                {
                    userID = userID.Text
                };
                admin.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Rejected");
                response.Dispose();
                client.Dispose();
            }
        }