Esempio n. 1
0
        private async void Button_Login_ClickAsync(object sender, EventArgs e)
        {
            HttpClient client = new HttpClient();
            string     pw     = EncryptionDecryption.ComputeSha256Hash(userPw.Text);
            var        uri    = new Uri(string.Format("http://apupay.azurewebsites.net/api/Shop?username="******"&password="******"application/json"));
            response = client.GetAsync(uri).Result;
            if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
            {
                string x = await response.Content.ReadAsStringAsync();

                ShopMenu sm = new ShopMenu()
                {
                    userID   = userID.Text,
                    itemJson = x
                };
                sm.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Rejected");
                response.Dispose();
                client.Dispose();
            }
        }
Esempio n. 2
0
        private async void button1_Click(object sender, EventArgs e)
        {
            if (textBox3.Text != "" && textBox2.Text != "" && textBox1.Text != "")
            {
                HttpClient          client = new HttpClient();
                string              pw     = EncryptionDecryption.ComputeSha256Hash(textBox3.Text);
                var                 uri    = new Uri(string.Format("http://apupay.azurewebsites.net/api/Shop?username="******"&password="******"application/json"));
                response = client.GetAsync(uri).Result;
                if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    string              itemname = textBox1.Text;
                    decimal             price    = Convert.ToDecimal(textBox2.Text);
                    HttpClient          clien1t  = new HttpClient();
                    var                 uri1     = new Uri(string.Format("https://apupay.azurewebsites.net/api/Shop?storeID=" + userid + "&item=" + itemname + "&price=" + price));
                    HttpResponseMessage response1;
                    clien1t.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var content = new StringContent(String.Empty, Encoding.UTF8, "application/json");
                    response1 = await client.PostAsync(uri1, content);

                    if (response1.StatusCode == System.Net.HttpStatusCode.Accepted)
                    {
                        MessageBox.Show("Accepted");
                    }
                    else
                    {
                        shop.Show();
                        this.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show("Error");
            }
        }