public async Task <IActionResult> Get(string albumName)
        {
            var albums = await _lastFmServiceAgent.GetAlbums(albumName);

            if (albums != null)
            {
                var stringUserId = Helpers.UserService.GetCurrentUserId(this.User);
                if (string.IsNullOrWhiteSpace(stringUserId))
                {
                    return(Unauthorized());
                }

                if (Int32.TryParse(stringUserId, out var userId))
                {
                    foreach (var album in albums)
                    {
                        album.FavoriteAlbumId = await
                                                _favoriteAlbumBusiness.GetFavoriteAlbumsByAlbumNameAndArtistName(album.Name, album.Artist,
                                                                                                                 userId);
                    }
                }

                return(Ok(albums));
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> Get(string albumName)
        {
            var response = await _lastFmServiceAgent.GetAlbums(albumName);

            if (response != null)
            {
                return(Ok(response));
            }

            return(Ok(new List <Album>()));
        }