public static ObservableCollection <HotDataItem> LoadHotItemsList() { ObservableCollection <HotDataItem> data = new ObservableCollection <HotDataItem>(); HotDataItem item1 = new HotDataItem() { BoardGameName = "Design time HotItems item", YearPublished = 1999 }; data.Add(item1); HotDataItem item2 = new HotDataItem() { BoardGameName = "Design time HotItems item - second item", YearPublished = 2993 }; data.Add(item2); HotDataItem item3 = new HotDataItem() { BoardGameName = "Design time HotItems item - third item", YearPublished = 996 }; data.Add(item3); return(data); }
internal async Task <ObservableCollection <HotDataItem> > LoadHotItemsList() { ObservableCollection <HotDataItem> hotItems = new ObservableCollection <HotDataItem>(); if (ShouldUpdateData()) // && has not download for X hours { Messenger.Default.Send(new ProgressMessage() { State = ProgressMessage.ProgressState.Started, Message = "Downloading popular games..." }); // update hotItems in background await Task.Run(async() => { var apihotItems = await Client.LoadHotItems(); if (apihotItems != null) { var rootFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("CoverPics", CreationCollisionOption.OpenIfExists); foreach (var item in apihotItems) { var temp = new HotDataItem(item); await SaveImage(rootFolder, item.ThumbnailWeb, temp.ThumbnailPath); hotItems.Add(temp); } StorageService.SaveAllHotItems(hotItems); } }); Messenger.Default.Send(new ProgressMessage() { State = ProgressMessage.ProgressState.Finished }); } return(hotItems); }