示例#1
0
 /// <summary>
 /// Method to invoke when the SelectSong command is executed.
 /// </summary>
 private void SelectSong(Song s)
 {
     SelectedSong       = s;
     IsSongVisible      = s != null;
     IsSongValid        = s.TimingLink != null;//s.ModelLinks != null && s.ModelLinks.Any(x => x.Link != null);
     IsSongViewSelected = true;
 }
示例#2
0
        private static Dictionary <string, List <Song> > MapSongs(List <Model.ExternalVendorInventory.Song> songs)
        {
            Dictionary <string, List <Song> > songMap = new Dictionary <string, List <Song> >();

            foreach (var song in songs)
            {
                try
                {
                    var s = new Song
                    {
                        Artist     = song.Artist.Trim(),
                        CategoryId = song.CategoryId.Trim(),
                        Creator    = song.Creator.Trim(),
                        Title      = song.Title.Trim()
                    };

                    if (!string.IsNullOrEmpty(song.Weblink))
                    {
                        if (Uri.TryCreate(song.Weblink, UriKind.Absolute, out var link))
                        {
                            s.SongLink = link;
                        }
                        else
                        {
                            Logging.Info($"Song link for {s.Title} by {s.Artist} could not be parsed: {song.Weblink}");
                        }
                    }
                    if (!string.IsNullOrEmpty(song.Download))
                    {
                        if (Uri.TryCreate(song.Download, UriKind.Absolute, out var link))
                        {
                            s.TimingLink = link;
                        }
                        else
                        {
                            Logging.Info($"Timing link for {s.Title} by {s.Artist} could not be parsed: {song.Download}");
                        }
                    }


                    if (songMap.TryGetValue(s.CategoryId, out var catProducts))
                    {
                        catProducts.Add(s);
                    }
                    else
                    {
                        songMap.Add(s.CategoryId, new List <Song>(new[] { s }));
                    }
                }
                catch (Exception e)
                {
                    Logging.Error(e, "An error occured paring song.");
                }
            }

            return(songMap);
        }