private async Task LoadDataAsync() { Items.Clear(); var hitNewsData = await _httpClient.GetNewsAsync(); foreach(var hit in hitNewsData) { var source = hit.Source; var newsItem = new NewsItem { Body = source.Body, BodyHtml = source.BodyHtml, Charset = source.Charset, ContentLength = source.ContentLength, Description = source.Description, Id = hit.Id, ImgUrl = source.ImgUrl, Locale = source.Locale, MimeType = source.MimeType, PublishedTime = source.PublishedTime, Title = source.Title, Url = source.Url }; Items.Add(newsItem); } RaisePropertyChanged(() => Items); }
//private async Task<NewsItemViewModel> InitializeAsync() //{ // await LoadDataAsync(); // return this; //} //public static Task<NewsItemViewModel> CreateAsync(INavigationService navSvc, IBernieHttpClient httpClient) //{ // var vm = new NewsItemViewModel(navSvc, httpClient); // return vm.InitializeAsync(); //} #endregion public async Task LoadDataAsync(string id) { _id = id; var hit = await _httpClient.GetNewsArticleAsync(_id); var source = hit.Source; Item = new NewsItem { Body = source.Body, BodyHtml = source.BodyHtml, Charset = source.Charset, ContentLength = source.ContentLength, Description = source.Description, Id = hit.Id, ImgUrl = source.ImgUrl, Locale = source.Locale, MimeType = source.MimeType, PublishedTime = source.PublishedTime, Title = source.Title, Url = source.Url }; RaisePropertyChanged(() => Item); }