Пример #1
0
        public SongsDiscoverModel DiscoverRelatedSongs(string name, string userToken, int maxCount)
        {
            var userAuthorization         = AuthorizationCache.Instance.GetByToken(userToken);
            var songRecommendationsResult = _songRepository.GetSimilarByTitle(name, userAuthorization.Id, maxCount);

            return(new SongsDiscoverModel
            {
                MatchedSong = string.IsNullOrEmpty(songRecommendationsResult.MatchedSongId)
                    ? null
                    : new SongItemModel
                {
                    Id = songRecommendationsResult.MatchedSongId,
                    Name = songRecommendationsResult.MatchedSongTitle,
                    Artist = ArtistMapper.ToArtistModel(songRecommendationsResult.MatchedSongArtist)
                },
                RecommendedSongs = songRecommendationsResult.RecommendedSongs.Select(
                    sr =>
                    new SongItemModel
                {
                    Id = sr.Song.Id,
                    Name = sr.Song.Title,
                    Artist = ArtistMapper.ToArtistModel(sr.Artist)
                })
            });
        }
Пример #2
0
        public ArtistModel GetById(string id)
        {
            var artist = _artistRepository.GetById(id);

            if (artist == null)
            {
                throw new NotFoundException(Messages.InvalidArtistId);
            }

            return(ArtistMapper.ToArtistModel(artist));
        }
Пример #3
0
        public IEnumerable <SongItemModel> GetSongRecommendations(string songId, string userToken, int maxCount)
        {
            var userAuthorization   = AuthorizationCache.Instance.GetByToken(userToken);
            var songRecommendations = _songRepository.GetSimilarById(songId, userAuthorization.Id, maxCount);

            return
                (songRecommendations.RecommendedSongs.Select(
                     sr =>
                     new SongItemModel
            {
                Id = sr.Song.Id,
                Name = sr.Song.Title,
                Artist = ArtistMapper.ToArtistModel(sr.Artist)
            }));
        }