internal async Task <CharacterProfileData> LoadMainCharacterDataAsync(string realm, string toonName) { //already loading and performing Task if (IsBusy) { return(null); } CharacterProfileData _loadedData = null; try { IsBusy = true; var httpClient = new HttpClient(); var json = await httpClient.GetStringAsync($"https://us.api.battle.net/wow/character/{realm}/{toonName}?locale=en_US&apikey={Helper.Constants.APIKEY}"); _loadedData = JsonConvert.DeserializeObject <CharacterProfileData>(json); //Wait out the loading of Race/Class data if still doing so await _loadStatus; } catch (HttpRequestException ex) { //This is fine, we display a message notice for bad data } catch (Exception ex) { //@TODO Need to handle other exceptions, maybe log them via HockeyApp? var str = ex.Message; } finally { IsBusy = false; } return(_loadedData); }
public CharacterMainViewModel(CharacterProfileData data) { _loadedData = data; //Never want this to be null }