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 stringUserId = UserService.GetCurrentUserId(User); if (string.IsNullOrWhiteSpace(stringUserId)) { return(Unauthorized()); } if (Int32.TryParse(stringUserId, out var userId)) { var response = await _favoriteArtistBusiness.GetFavoriteArtistsByName(artistName, userId); if (response != null) { return(Ok(response)); } return(NoContent()); } return(Unauthorized()); }