Example #1
0
        public async Task <IActionResult> Get(string artistName)
        {
            var artist = await _lastFmServiceAgent.GetArtist(artistName);

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

                if (Int32.TryParse(stringUserId, out var userId))
                {
                    var response = await _favoriteArtistBusiness.GetFavoriteArtistsByName(artist.Name, userId);

                    int?favoriteArtistId = response?.FirstOrDefault()?.FavoriteArtistId;
                    if (favoriteArtistId != null)
                    {
                        artist.FavoriteArtistId = (int)favoriteArtistId;
                    }
                }
                return(Ok(artist));
            }

            return(NoContent());
        }
        public async Task <IActionResult> Get(string artistName)
        {
            var response = await _lastFmServiceAgent.GetArtist(artistName);

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

            return(Ok(new Artist()));
        }