internal static Playlist ToDto(Entities.Playlist playlist, bool include_relations = false) { if (playlist == null) { return(null); } if (include_relations) { return(new Playlist { Id = playlist.Id, Description = playlist.Description, User = AccountRepository.ToDto(playlist.User), Tracks = playlist.Tracks .OrderBy(t => t.Index) .Select(t => SongRepository.ToDto(t.Song, false, false)) .ToList() }); } else { return(new Playlist { Id = playlist.Id, Description = playlist.Description }); } }
internal static Entities.Playlist ToEntity(Playlist playlist, MintPlayerContext mintplayer_context) { if (playlist == null) { return(null); } var entity_playlist = new Entities.Playlist { Id = playlist.Id, Description = playlist.Description }; #region Tracks entity_playlist.Tracks = playlist.Tracks.Select((song, index) => { var entity_song = mintplayer_context.Songs.Find(song.Id); return(new Entities.PlaylistSong(entity_playlist, entity_song) { Index = index }); }).ToList(); #endregion return(entity_playlist); }
protected override async Task Handle(AddPlaylistCommand command, CancellationToken cancellationToken) { var playlist = new Entities.Playlist(command.PlaylistId, command.Name, command.UserId); await _repository.CreateAsync(playlist); }