예제 #1
0
파일: RestService.cs 프로젝트: ararog/Ow-WP
        public async Task<List<Contact>> SyncContacts(User user, List<Contact> contacts)
        {
            HttpStringContent postContent = new HttpStringContent(JsonConvert.SerializeObject(contacts));
            postContent.Headers["Content-Type"] = "application/json";

            try 
            {
                string path = string.Format("/api/v1/users/{0}/contacts/sync", user.Id);

                HttpResponseMessage response = await client.PostAsync(
                    new Uri(serviceUrl, path), postContent);

                if (response.IsSuccessStatusCode) 
                {
                    string content = await response.Content.ReadAsStringAsync();
                    List<Contact> syncedContacts = JsonConvert.DeserializeObject<List<Contact>>(content);

                    return syncedContacts;
                }
            }
            catch
            {

            }

            return null;
        }
예제 #2
0
파일: Session.cs 프로젝트: ararog/Ow-WP
 public void LoadData()
 {
     try
     {
         string data = (String) preferences["user"];
         User = JsonConvert.DeserializeObject<User>(data);
     }
     catch(Exception e)
     {
         User = null;
     }
 }
예제 #3
0
파일: RestService.cs 프로젝트: ararog/Ow-WP
        public async Task<List<Contact>> LoadContacts(User user)
        {
            string path = string.Format("/api/v1/users/{0}/contacts", user.Id);

            HttpResponseMessage response = await client.GetAsync(
                new Uri(serviceUrl, path));

            try 
            { 
                if (response.IsSuccessStatusCode) 
                {
                    string content = await response.Content.ReadAsStringAsync();
                    List<Contact> contacts = JsonConvert.DeserializeObject<List<Contact>>(content);

                    return contacts;
                }
            }
            catch
            {

            }

            return null;
        }