public async Task <IActionResult> Get(string artistName) { try { var topAlbums = await _lastFmServiceAgent.GetTopAlbums(artistName).ConfigureAwait(false); if (topAlbums != null) { var stringUserId = Helpers.UserService.GetCurrentUserId(User); if (string.IsNullOrWhiteSpace(stringUserId)) { return(Unauthorized()); } if (Int32.TryParse(stringUserId, out var userId)) { foreach (var topAlbum in topAlbums) { topAlbum.FavoriteAlbumId = await _favoriteAlbumBusiness.GetFavoriteAlbumsByAlbumNameAndArtistName(topAlbum.Name, artistName, userId); } } return(Ok(topAlbums)); } return(NoContent()); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <IActionResult> Get(string artistName) { try { var response = await _lastFmServiceAgent.GetTopAlbums(artistName); if (response != null) { return(Ok(response)); } } catch (Exception e) { Console.WriteLine(e); throw; } return(Ok(new List <TopAlbum>())); }