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); }
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); } }
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; } }