예제 #1
0
        public async Task<bool> CallWebApiAddReunion(Reunion reunion, ObservableCollection<Anime> selectedAnime)
        {
            HttpClient client = new HttpClient();
            string json = JsonConvert.SerializeObject(reunion);
            HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync("http://scoutome.azurewebsites.net/api/reunions", content);
            if (response.IsSuccessStatusCode)
            {
                //    Pour ajouter les présences  
                for (int i = 0; i < selectedAnime.Count(); i++)
                {
                    Presences pre = new Presences();
                    pre.codeReunion = reunion.codeReunion;
                    pre.useless = 1;
                    pre.codeAnime = selectedAnime[i].codeAnime;

                    string jsonPresence = JsonConvert.SerializeObject(pre);
                    HttpContent contentPresence = new StringContent(jsonPresence, Encoding.UTF8, "application/json");
                    HttpResponseMessage responsefav = await client.PostAsync("http://scoutome.azurewebsites.net/api/presences", contentPresence);
                    if (responsefav.IsSuccessStatusCode)
                    {

                    }
                }

            }
            return false;
        }
        private async Task<bool> AddPresences(Reunion reunion, ObservableCollection<Anime> selectedAnime)
        {
            //    Pour ajouter les présences  
            for (int i = 0; i < selectedAnime.Count(); i++)
            {
                Presences pre = new Presences();
                pre.codeReunion = reunion.codeReunion;
                pre.useless = 1;
                pre.codeAnime = selectedAnime[i].codeAnime;

                string jsonPresence = JsonConvert.SerializeObject(pre);
                HttpContent contentPresence = new StringContent(jsonPresence, Encoding.UTF8, "application/json");
                HttpResponseMessage response = await client.PostAsync(urlApi+"presences", contentPresence);
                if (response.IsSuccessStatusCode)
                {
                    
                }
            }
            return true;
        }