Example #1
0
        public static SongItemModel ToSongItemModel(SongDetailsDto songDetails)
        {
            if (songDetails == null)
            {
                return(null);
            }

            return(new SongItemModel
            {
                Id = songDetails.Song.Id,
                Name = songDetails.Song.Title,
                Artist = ArtistMapper.ToArtistModel(songDetails.Artist)
            });
        }
Example #2
0
        public static Song ToSong(SongModel songModel)
        {
            if (songModel == null)
            {
                return(null);
            }

            return(new Song
            {
                Id = songModel.Id,
                Title = songModel.Name,
                Url = songModel.Url,
                Artist = ArtistMapper.ToArtist(songModel.Artist),
                SongCategory = SongCategoryMapper.ToSongCategory(songModel.SongCategory),
                Instruments = songModel.Instruments.Select(InstrumentMapper.ToInstrument),
                Tags = songModel.Tags.Select(TagMapper.ToTag)
            });
        }
Example #3
0
        public static SongModel ToSongModel(SongDetailsDto songDetails)
        {
            if (songDetails == null)
            {
                return(null);
            }

            return(new SongModel
            {
                Id = songDetails.Song.Id,
                Name = songDetails.Song.Title,
                Url = songDetails.Song.Url,
                Artist = ArtistMapper.ToArtistModel(songDetails.Artist),
                SongCategory = SongCategoryMapper.ToSongCategoryModel(songDetails.SongCategory),
                //TODO: Have a look over here
                Tags = songDetails.Tags.GroupBy(t => t.Id).Select(grp => TagMapper.ToTagModel(grp.FirstOrDefault())),
                Instruments = songDetails.Instruments.GroupBy(i => i.Id).Select(grp => InstrumentMapper.ToInstrumentModel(grp.FirstOrDefault()))
            });
        }