Пример #1
0
        public static async Task <UserPreferenceDTO> GetUserPrefsAsync()
        {
            UserPreferenceDTO prefs = null;

            try
            {
                var response = await _httpClient.GetAsync(WebAPIConstants.GetSetUserPrefs);

                if (response.IsSuccessStatusCode)
                {
                    prefs = await response.Content.ReadAsAsync <UserPreferenceDTO>();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("WebAPI.GetUserPrefs failed: " + ex.Message);
            }

            return(prefs);
        }
Пример #2
0
        public static async Task <Boolean> SetUserPrefsAsync(UserPreferences current, List <String> ActiveCategories)
        {
            UserPreferenceDTO prefs = new UserPreferenceDTO()
            {
                ConversationLimit = current.ConversationLimit,
                SortOrder         = 0,
                Categories        = ActiveCategories
            };

            try
            {
                var response = await _httpClient.PutAsJsonAsync(WebAPIConstants.GetSetUserPrefs, prefs);

                return(response.IsSuccessStatusCode);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("WebAPI.SetUserPrefs failed: " + ex.Message);
                return(false);
            }
        }
Пример #3
0
 public static async Task<Boolean> SetUserPrefsAsync(UserPreferences current, List<String> ActiveCategories)
 {
     UserPreferenceDTO prefs = new UserPreferenceDTO() 
     {
         ConversationLimit = current.ConversationLimit,
         SortOrder = 0,
         Categories = ActiveCategories
     };
                            
     try
     {
         var response = await _httpClient.PutAsJsonAsync(WebAPIConstants.GetSetUserPrefs, prefs);
         return response.IsSuccessStatusCode;
     }
     catch (Exception ex)
     {
         Debug.WriteLine("WebAPI.SetUserPrefs failed: " + ex.Message);
         return false;
     }
 }