private async void ImportGameButton_Click(object sender, RoutedEventArgs e)
        {
            // open file picker
            // select the file
            // get display name and extension of file
            // find platform by file type
            // search in launch box by displayname (name, platform, notes, picture)
            // for each search result check if item.platform is equal to platform by file type
            // if true return the item
            try
            {
                var picker = new Windows.Storage.Pickers.FileOpenPicker();
                picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.List;
                picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
                picker.FileTypeFilter.Add(".nes");

                Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();

                if (file != null)
                {
                    string extension = StorageService.GetFileExtension(file);
                    Game   game      = new Game()
                    {
                        Title = file.DisplayName, Platform = "", Notes = file.Path
                    };
                    ObservableCollection <Game> a = await LaunchBoxScraper.SearchGame(file.DisplayName);

                    foreach (var item in a)
                    {
                        if (item.Platform == "Nintendo Entertainment System")
                        {
                            await NotificationService.DisplaySimpleMessageDialog(item.Title, item.Platform);
                        }
                    }
                    await DatabaseService.AddGame(game);

                    GamesList.Add(game);
                }
                else
                {
                    await NotificationService.DisplaySimpleMessageDialog("", "Operation cancelled.");
                }
            }
            catch (Exception error)
            {
                await NotificationService.DisplaySimpleMessageDialog("", error.Message);

                throw;
            }



            // *************** delete ************************
            FutureAccessListTextBlock.Text = "";
            IEnumerable <AccessListEntry> accessListEntries = StorageService.GetFutureAccessListEntries();

            FutureAccessListEntries = new ObservableCollection <AccessListEntry>(accessListEntries);
            // ***********************************************
        }
Esempio n. 2
0
 public Task <GameInfo> Add(GameInfo game)
 {
     return(DBService.AddGame(game));
 }