Exemplo n.º 1
0
        private async Task <IEnumerable <Release> > GetReleases()
        {
            try
            {
                //this methods needs the client Id and the client secret en we will set them in the app settings
                var token = await _spotifyAccountService.GetToken(_configuration["Spotify:ClientId"], _configuration["Spotify:ClientSecret"]);

                //invoke method
                var newReleases = await _spotifyService.GetNewReleases("AR", 10, token);

                return(newReleases);
            }
            catch (Exception ex)
            {
                Debug.Write(ex);
                return(Enumerable.Empty <Release>());
            }
        }
Exemplo n.º 2
0
        private async Task <IEnumerable <Release> > GetReleases()
        {
            try
            {
                var token = await _spotifyAccountService.GetToken(
                    _configuration["Spotify:ClientId"],
                    _configuration["Spotify:ClientSecret"]);

                var newReleases = await _spotifyService.GetNewReleases("US", 20, token);

                return(newReleases);
            }
            catch (Exception ex)
            {
                Debug.Write(ex);

                return(Enumerable.Empty <Release>());
            }
        }
Exemplo n.º 3
0
        // GET: Collect
        public ActionResult Index()
        {
            // Get new releases
            var albums = _spotifyService.GetNewReleases();

            // Get categories
            var categories          = _spotifyService.GetCategories();
            var categorySelectItems = new List <SelectListItem>();

            foreach (var category in categories.items)
            {
                categorySelectItems.Add(new SelectListItem
                {
                    Value = category.id,
                    Text  = category.name
                });
            }

            // Get genres
            var genres = _spotifyService.GetGenres();
            var genreSelectListItems = new List <SelectListItem>();

            foreach (var genre in genres)
            {
                genreSelectListItems.Add(new SelectListItem
                {
                    Value = genre,
                    Text  = genre
                });
            }

            return(View(new CollectViewModel
            {
                NewReleases = albums,
                Categories = categorySelectItems,
                Genres = genreSelectListItems
            }));
        }