Exemple #1
0
        public async Task <IActionResult> GetUserAlbums(string userId)
        {
            if (!int.TryParse(userId, out var validUserId))
            {
                return(UnprocessableEntity());
            }

            var albumsForUser = await _albumsRepository.GetAlbumByUserId(validUserId);

            if (!albumsForUser.Any())
            {
                return(NotFound());
            }

            return(Ok(
                       new UserResponse(
                           HypermediaLinkBuilder.ForUsersDiscovery(Url, validUserId),
                           new Dictionary <string, string>()
            {
                { "userId", userId }
            },
                           albumsForUser
                           )
                       ));
        }