Exemple #1
0
        public async Task <IEnumerable <UserBpmResponse> > SendBPM(int _id_user)
        {
            HttpClient client   = GetClient();
            BpmManager manager  = new BpmManager();
            string     URL_List = manager.test().ToString();

            string url         = URL_List;
            string contentType = "application/json";

            JObject json = new JObject
            {
                { "ID_user", _id_user }
            };

            var response = await client.PostAsync(url, new StringContent(json.ToString(), Encoding.UTF8, contentType));

            var data = await response.Content.ReadAsStringAsync();

            Dictionary <string, string> text      = new Dictionary <string, string>();
            List <UserBpmResponse>      lista_bpm = new List <UserBpmResponse>();

            response.EnsureSuccessStatusCode();
            string responseBody = await response.Content.ReadAsStringAsync();

            try
            {
                lista_bpm = JsonConvert.DeserializeObject <List <UserBpmResponse> >(responseBody);
                Console.WriteLine(lista_bpm.Count);
            }
            catch (Exception ex) {
                Console.WriteLine("Excepetion" + ex.Message);
            }
            return(lista_bpm);
        }
Exemple #2
0
        public async Task <IEnumerable <BPM> > GetBPM()
        {
            HttpClient client   = GetClient();
            BpmManager manager  = new BpmManager();
            string     URL_List = manager.test().ToString();

            HttpResponseMessage response = await client.GetAsync(URL_List);

            response.EnsureSuccessStatusCode();
            string responseBody = await response.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <IEnumerable <BPM> >(responseBody));
        }