Beispiel #1
0
        public static async Task <Uri> PostAsync(FormularioSend formularioSend)
        {
            using (var stringContent = new StringContent(
                       JsonConvert.SerializeObject(formularioSend), Encoding.UTF8, "application/json"))
            {
                var response = await client.PostAsync(@"http://localhost:81/", stringContent);

                return(response.Headers.Location);
            }
        }
Beispiel #2
0
        private async Task RunAsync()
        {
            client.BaseAddress = new Uri("http://localhost:81");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            try
            {
                var send = new FormularioSend
                {
                    Id       = new Random().Next(),
                    Price    = double.Parse(preco.Text),
                    Quantity = int.Parse(quantidade.Text),
                    Side     = rbCompra.Checked ? "buy" : "sell",
                    Symbol   = symbol.Text
                };

                var url = await PostAsync(send);
            } catch (Exception ex)
            {
                throw;
            }
        }