public async override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { try { // Fill Genres and Kinds dictionaries GenresDictionary = await SoundCloudHelper.GetGenres(); KindsDictionary = await SoundCloudHelper.GetKinds(); foreach (var g in GenresDictionary) { Genres.Add(g.Value); } foreach (var k in KindsDictionary) { Kinds.Add(k.Value); } // Select first Genre and Kind SelectedGenre = Genres.FirstOrDefault(); SelectedKind = Kinds.FirstOrDefault(); await base.OnNavigatedToAsync(parameter, mode, state); } catch (Exception ex) { Logger.LogError(this, ex.Message); ShowErrorMessage("There was an error during fetching tracks from SoundCloud."); } }
void onTglGenre(object gi) { Bpr.BeepOk(); var intGnr = Convert.ToInt16(gi); var genre = GenreFilter.FirstOrDefault(r => r.ID == intGnr); if (genre != null) { GenreFilter.Remove(genre); } else { GenreFilter.Add(Genres.FirstOrDefault(r => r.ID == intGnr)); } }
public bool Contains(IEnumerable <string> genres, out DirectoryInfo dir) { var genreDir = Genres.FirstOrDefault(gd => genres.Any(genre => gd.Name.Trim().Equals(genre.Trim(), StringComparison.OrdinalIgnoreCase))); Log($"Checking if GenreMove contains any of the following genres:{string.Join(",",genres)}"); dir = null; bool contains = genreDir != null; if (contains) { Log($"Found matching genreDir {genreDir}. Returning true"); dir = new DirectoryInfo(genreDir.Directory); } return(contains); }
public static void Seed(ApplicationContext context) { if (!context.Genres.Any()) { context.Genres.AddRange(Genres); } if (!context.Films.Any()) { context.AddRange ( new Film { Name = "Harry Potter", Rating = 10, Image = "https://sites.google.com/site/znakomstvogp/_/rsrc/1363533236445/home/1235573806_garri_potter1.jpg", Genre = Genres.FirstOrDefault(x => x.Name == "Fantasy") }, new Film { Name = "Avatar", Rating = 3, Image = "https://img-tv.vl.ru/fhd/0f3f565c929ea34315aabd160a67668c19012c.jpg", Genre = Genres.FirstOrDefault(x => x.Name == "Fantasy") }, new Film { Name = "One Home", Rating = 3, Image = "https://ptzgovorit.ru/sites/default/files/styles/700x400/public/original_nodes/odin_doma.jpg?itok=DiNYwBPj", Genre = Genres.FirstOrDefault(x => x.Name == "Comedy") } ); context.SaveChanges(); } }
private void PopulateSongs() { Songs.Add(new Song { Artist = "311", AlbumId = 1, Title = "Amber", Year = 2004, Rating = 5, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "A Perfect Circle", AlbumId = 2, Title = "The Noose", Year = 2003, Rating = 5, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "A Perfect Circle", AlbumId = 2, Title = "Blue", Year = 2003, Rating = 4, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "A Perfect Circle", AlbumId = 2, Title = "Pet", Year = 2003, Rating = 3, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Daft Punk", AlbumId = 3, Title = "The Game Has Changed", Year = 2010, Rating = 4, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Daft Punk", AlbumId = 3, Title = "End Of Line", Year = 2010, Rating = 3, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Daft Punk", AlbumId = 3, Title = "C.L.U", Year = 2010, Rating = 3, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Daft Punk", AlbumId = 3, Title = "Tron Legacy (End Titles)", Year = 2010, Rating = 4, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Deadmau5", AlbumId = 4, Title = "Some Chords", Year = 2013, Rating = 5, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Franklin Brothers", AlbumId = 5, Title = "She Won", Year = 2011, Rating = 4, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Metallica", AlbumId = 6, Title = "Blackened", Year = 1990, Rating = 4, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Metallica", AlbumId = 6, Title = "...And Justice for All", Year = 1990, Rating = 5, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Metallica", AlbumId = 6, Title = "One", Year = 1990, Rating = 5, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Modest Mouse", AlbumId = 7, Title = "One", Year = 1990, Rating = 5, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Rage Against the Machine", AlbumId = 8, Title = "Killing in the Name", Year = 1992, Rating = 4, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Rage Against the Machine", AlbumId = 9, Title = "Bulls on Parade", Year = 1996, Rating = 5, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Tool", AlbumId = 10, Title = "The Pot", Year = 2006, Rating = 5, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Tool", AlbumId = 10, Title = "Rosetta Stoned", Year = 2006, Rating = 5, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Tool", AlbumId = 10, Title = "Wings for Marie (Pt 1)", Year = 2006, Rating = 4, Length = RandomSongLength() }); Songs.Add(new Song { Artist = "Tool", AlbumId = 10, Title = "10,000 Days (Wings Pt 2)", Year = 2006, Rating = 5, Length = RandomSongLength() }); // Add Genres to Songs var alternativeGenre = Genres.FirstOrDefault(g => g.Name == "Alternative"); var altRockGenre = Genres.FirstOrDefault(g => g.Name == "Alt Rock"); var jazzGenre = Genres.FirstOrDefault(g => g.Name == "Jazz"); var metalGenre = Genres.FirstOrDefault(g => g.Name == "Metal"); var progressiveGenre = Genres.FirstOrDefault(g => g.Name == "Progressive"); var rapGenre = Genres.FirstOrDefault(g => g.Name == "Rap"); var rockGenre = Genres.FirstOrDefault(g => g.Name == "Rock"); var technoGenre = Genres.FirstOrDefault(g => g.Name == "Techno"); Songs .Where(s => s.Artist == "311").ToList() .ForEach(s => s.Genres.Add(alternativeGenre)); Songs .Where(s => s.Artist == "A Perfect Circle").ToList() .ForEach(s => s.Genres.Add(progressiveGenre)); Songs .Where(s => s.Artist == "Daft Punk" || s.Artist == "DeadMau5").ToList() .ForEach(s => s.Genres.Add(technoGenre)); Songs .Where(s => s.Artist == "Franklin Brothers").ToList() .ForEach(s => s.Genres.Add(jazzGenre)); Songs .Where(s => s.Artist == "Metallica").ToList() .ForEach(s => s.Genres.Add(metalGenre)); Songs .Where(s => s.Artist == "Modest Mouse").ToList() .ForEach(s => s.Genres.Add(altRockGenre)); Songs .Where(s => s.Artist == "Rage Against the Machine").ToList() .ForEach(s => { s.Genres.Add(metalGenre); s.Genres.Add(rapGenre); }); Songs .Where(s => s.Artist == "Tool").ToList() .ForEach(s => { s.Genres.Add(metalGenre); s.Genres.Add(progressiveGenre); }); }
private async Task <bool> CheckForGameData() { var genres = _settingsService.Get("Genres", default(List <Genre>)); if (genres != default(List <Genre>)) { await _asyncStorageService.WriteAllTextAsync(Constants.GenreDataFile, await JsonConvert.SerializeObjectAsync(genres)); _settingsService.Reset("Genres"); } else { if (!await _asyncStorageService.FileExistsAsync(Constants.GenreDataFile)) { return(false); } var genreJson = await _asyncStorageService.ReadAllTextAsync(Constants.GenreDataFile); genres = await JsonConvert.DeserializeObjectAsync <List <Genre> >(genreJson); if (genres == null || !genres.Any()) { return(false); } var allGenreCheck = genres.FirstOrDefault(x => x.Name.Equals(GameViewModel.AllGenres)); if (allGenreCheck == default(Genre)) { genres.Insert(0, new Genre { Name = GameViewModel.AllGenres }); } var comedyGenreCheck = genres.FirstOrDefault(x => x.Name.Equals("Comedy")); if (comedyGenreCheck != default(Genre)) { genres.Remove(comedyGenreCheck); } } Genres = genres; App.SettingsWrapper.AppSettings.DefaultGenre = Genres.FirstOrDefault(x => x.Name.Equals(App.SettingsWrapper.AppSettings.DefaultGenre.Name)); if (SimpleIoc.Default.GetInstance <GameViewModel>() == null) { return(false); } Messenger.Default.Send(new NotificationMessage(genres, Constants.Messages.HereAreTheGenresMsg)); if (!await _asyncStorageService.FileExistsAsync(Constants.GameDataFile)) { return(false); } var tracksJson = await _asyncStorageService.ReadAllTextAsync(Constants.GameDataFile); try { var tracks = await JsonConvert.DeserializeObjectAsync <List <Product> >(tracksJson); if (tracks.Any()) { Messenger.Default.Send(new NotificationMessage(tracks, Constants.Messages.HereAreTheTracksMsg)); return(true); } } catch (Exception ex) { Log.ErrorException("Deserializing tracks", ex); } return(false); }