public LyricsView(VkAudio audio)
        {
            InitializeComponent();

            _viewModel       = new LyricsViewModel();
            this.DataContext = _viewModel;
            _viewModel.Track = audio;
        }
        public IActionResult Index(string id)
        {
            List <Track> tracks        = HttpContext.Session.Get <List <Track> >("tracks");
            Track        selectedTrack = tracks.Where(t => t.ID == id).First();

            HttpContext.Session.Set <Track>("track", selectedTrack);

            MusixMatchAPI api = new MusixMatchAPI();

            Lyrics result = HttpContext.Session.Get <Lyrics>("lyrics");

            if (result == null)
            {
                result = api.GetLyrics(new Models.Track()
                {
                    ID = id
                }, ApiManager.GetKey(Constants.Services.MusixMatch));
                HttpContext.Session.Set <Lyrics>("lyrics", result);
            }

            string token    = ApiManager.GetKey(Constants.Services.Spotify);
            bool   hasToken = !string.IsNullOrEmpty(token);

            List <Playlist>       playlists     = null;
            List <SelectListItem> playlistItems = new List <SelectListItem>();

            if (hasToken)
            {
                SpotifyService spotifyService = new SpotifyService();
                playlists = spotifyService.GetPlaylists(token);
                foreach (var pl in playlists)
                {
                    playlistItems.Add(new SelectListItem()
                    {
                        Value = pl.ID,
                        Text  = pl.Name
                    });
                }
            }

            LyricsViewModel viewModel = new LyricsViewModel()
            {
                Lyrics     = result,
                Playlists  = playlistItems,
                HasToken   = hasToken,
                TrackAdded = TempData["addedTrack"] != null
            };

            return(View(viewModel));
        }
Beispiel #3
0
 public LyricsPage(string Lyrics)
 {
     InitializeComponent();
     BindingContext = new LyricsViewModel(Lyrics);
 }