public void AddTrackInPlaylistUser(string userId, string playlistName, int trackId) { var playlist = userRepository.GetPlaylistWithTracksByUserIdAndPlaylistName(userId, playlistName); if (playlist == null) { playlistDomain.CreatePlaylistAndUserId(playlistName, userRepository.GetUserById(userId)); } var track = trackRepository.GetTrackById(trackId); if (!playlist.Tracks.Contains(track)) { playlist.Tracks.Add(track); playlistDomain.SaveChanges(); } }
public void AddPlaylist(CreatePlaylistViewModel playlistModel) { Playlist playlist = Mapper.Map <CreatePlaylistViewModel, Playlist>(playlistModel); playlist.PlaylistImage.ImageData = GetArray(playlistModel.PlaylistImage); playlistDomainService.Entry(playlist).State = EntityState.Added; playlistDomainService.SaveChanges(); }