Beispiel #1
0
        public static async Task PutNote(Note note)
        {
            using (HttpClient client = new HttpClient())
            {
                Contact contact = RestAPIConverter.convertFromNote(note);
                string  json    = JsonConvert.SerializeObject(contact);

                await client.PutAsync(uri.ToString() + note.Id, new StringContent(json, Encoding.UTF8, "application/json"));
            }
        }
Beispiel #2
0
        public static async Task <Note> GetNote(int noteId)
        {
            using (HttpClient client = new HttpClient())
            {
                string json = await client.GetStringAsync(uri.ToString() + noteId);

                Contact contact = JsonConvert.DeserializeObject <Contact>(json);
                Note    note    = RestAPIConverter.convertToNote(contact);
                return(note);
            }
        }
Beispiel #3
0
        public static async Task <List <Note> > GetAllNotes()
        {
            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(uri);

                string json = await response.Content.ReadAsStringAsync();

                List <Contact> contacts = JsonConvert.DeserializeObject <List <Contact> >(json);
                return(RestAPIConverter.convertToNotesList(contacts));
            }
        }