Beispiel #1
0
        protected async void btnInsert_Click(object sender, EventArgs e)
        {
            int idRest = Convert.ToInt16(Session["idRest"]);
            HttpClient httpClient = new HttpClient();

            string cu = HashPassword(textBoxSenha.Text);

            httpClient.BaseAddress = new Uri(ip);
            Models.GerentePedido f = new Models.GerentePedido
            {
                Usuario = textBoxUsuario.Text,
                Senha = cu,
                Restaurante_id = idRest
            };

            List<Models.GerentePedido> fl = new List<Models.GerentePedido>();

            fl.Add(f);

            string s = "=" + JsonConvert.SerializeObject(fl, Newtonsoft.Json.Formatting.None,
                            new JsonSerializerSettings
                            {
                                NullValueHandling = NullValueHandling.Ignore
                            });

            var content = new StringContent(s, Encoding.UTF8, "application/x-www-form-urlencoded");

            HttpResponseMessage message = await httpClient.PostAsync("/20131011110061/api/gerentepedido", content);

            Reload();
        }
Beispiel #2
0
        protected async void btnUpdate_Click(object sender, EventArgs e)
        {
            int idRest = Convert.ToInt16(Session["idRest"]);
            HttpClient httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri(ip);
            Models.GerentePedido f = new Models.GerentePedido
            {
                Usuario = textBoxUsuario.Text,
                Senha = textBoxSenha.Text,
                Restaurante_id = idRest
            };

            string s = "=" + JsonConvert.SerializeObject(f);

            var content = new StringContent(s, Encoding.UTF8, "application/x-www-form-urlencoded");

            await httpClient.PutAsync("/20131011110061/api/gerentepedido/" + textBoxUsuario.Text, content);

            Reload();
        }