public async void LoadFactAsync() { var fact = await Helpers.FactHelper.GetFactAsync(); this.CurrentFact = new FactInformation() { Id = Guid.NewGuid(), IsFavorite = false, Label = fact }; }
public async static Task <bool> RemoteFavoriteAsync(FactInformation fact) { bool successful = false; var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("Favorites", CreationCollisionOption.OpenIfExists); var file = await folder.GetFileAsync(fact.Id.ToString()); await file.DeleteAsync(); return(successful); }
public async static Task <bool> SaveFavoriteAsync(FactInformation fact) { bool successful = false; var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("Favorites", CreationCollisionOption.OpenIfExists); var file = await folder.CreateFileAsync(fact.Id.ToString()); fact.IsFavorite = true; string content = JsonConvert.SerializeObject(fact); await FileIO.WriteTextAsync(file, content); return(successful); }