public SongPlaylist Delete(SongPlaylist songPlaylist) { var result = _context.Remove(songPlaylist); _context.SaveChanges(); return(result.Entity); }
public SongPlaylist Create(SongPlaylist songPlaylist) { var result = _context.Add <SongPlaylist>(songPlaylist); _context.SaveChanges(); return(result.Entity); }
public void Post(PlaylistDetailsDTO value) //needs to be modified!!!!!!!! { Playlist model = new Playlist() { name = value.name, }; iPlaylistRepository.Create(model); for (int i = 0; i < value.moods.Count; i++) { PlaylistMood playlistMood = new PlaylistMood() { playlistId = model.id, moodId = value.moods[i].id }; iPlaylistMoodRepository.Create(playlistMood); } for (int i = 0; i < value.songs.Count; i++) { SongPlaylist songPlaylist = new SongPlaylist() { playlistId = model.id, songId = value.songs[i].id }; iSongPlaylistRepository.Create(songPlaylist); } iPlaylistRepository.Create(model); }
/// <summary> /// ConvertFromJson method. /// convert from jarray jtokens to the appropriate /// params for this window /// </summary> /// <param name="j"></param> public void ConvertFromJson(JArray j) { OriginalPlayList = JsonConvert.DeserializeObject <SongPlaylist>(j[0].ToString()); CurrentPlayList = new SongPlaylist(OriginalPlayList); CopyCurrentPlayList = new SongPlaylist(CurrentPlayList); CurrentGeners = new ObservableCollection <ExtensionInfo>(); TempoList = new ObservableCollection <ExtensionInfo>(); resolveGenres(CurrentPlayList); resolveTempo(CurrentPlayList); }
public void Post(SongPlaylistDTO value) { SongPlaylist model = new SongPlaylist() { songId = value.songId, playlistId = value.playlistId }; iSongPlaylistRepository.Create(model); }
//CreateSongPlaylist public bool AddSongsToPlaylist(SongPlaylistCreate model) { var newsong = new SongPlaylist() { NewPlaylistID = model.NewPlaylistID, SongID = model.SongID }; using (var ctx = new ApplicationDbContext()) { ctx.PlaylistOfSongs.Add(newsong); return(ctx.SaveChanges() == 1); } }
public void Put(int id, SongPlaylistDTO value) { SongPlaylist model = iSongPlaylistRepository.Get(id); if (value.songId != null) { model.songId = value.songId; } if (value.playlistId != null) { model.playlistId = value.playlistId; } iSongPlaylistRepository.Update(model); }
/// <summary> /// Called when a playlist name has been entered has been selected. /// </summary> /// <param name="selectedLibrary"></param> private async void NameEntered(string libraryName, NewLibraryNameDialogFragment libraryNameFragment) { string alertText = ""; // An empty library name is not allowed if (libraryName.Length == 0) { alertText = EmptyNameError; } else { // Check for a duplicate if (Libraries.LibraryNames.Contains(libraryName) == true) { alertText = DuplicateLibraryError; } else { // Create a library with a default source and display the source editing fragment Library newLibrary = new() { Name = libraryName }; await Libraries.AddLibraryAsync(newLibrary); // Add a source Source newSource = new() { Name = libraryName, AccessMethod = Source.AccessType.Local, FolderName = libraryName, LibraryId = newLibrary.Id }; await Sources.AddSourceAsync(newSource); // Add an empty NowPlaying list Playlist nowPlaying = new SongPlaylist() { Name = Playlists.NowPlayingPlaylistName, LibraryId = newLibrary.Id }; await Playlists.AddPlaylistAsync(nowPlaying); nowPlaying.SongIndex = -1; SourceSelectionDialogFragment.ShowFragment(CommandRouter.Manager, newLibrary, SourceSelected, BindDialog); } } // Display an error message if the playlist name is not valid. if (alertText.Length > 0) { NotificationDialogFragment.ShowFragment(CommandRouter.Manager, alertText); } else { // Dismiss the library name dialogue libraryNameFragment.Dismiss(); } }
public async Task AddSongToMainPlaylist(int idUser, int idSong) { var playlist = await GetUsersMainPlaylist(idUser); if (context.Set <SongPlaylist>().Where(s => s.SongId == idSong && s.PlaylistId == playlist.Id).Any()) { throw new System.ArgumentException(); } var songPlaylist = new SongPlaylist { SongId = idSong, PlaylistId = playlist.Id }; context.Set <SongPlaylist>().Add(songPlaylist); await SaveChanges(); }
/// <summary> /// ConvertToJson method. /// convert this window's parameters into a Jarray. /// specifically retrieve the user's playlist and convert /// it to Json /// </summary> /// <returns>Jarray with param</returns> public JArray ConvertToJson() { JArray j = new JArray(); DataTable dt = dataBase.ExecuteCommandWithResults(getPlaylistString()); ObservableCollection <string> temp = JsonConvert.DeserializeObject <ObservableCollection <string> >(QueryInterpreter.Instance.getQueryEntitesObject(QueryInterpreter.QueryType.ResolveInitialPlaylist, dt)); ObservableCollection <Song> songs = new ObservableCollection <Song>(); SongPlaylist playList = new SongPlaylist(); playList.User = user; foreach (string item in temp) { songs.Add(JsonConvert.DeserializeObject <Song>(item)); } playList.Songs = songs; j.Add(JsonConvert.SerializeObject(playList)); return(j); }
public void Put(int id, PlaylistDetailsDTO value) //needs to be modified { Playlist model = iPlaylistRepository.Get(id); if (value.name != null) { model.name = value.name; } if (value.moods != null) { foreach (Mood mood in value.moods) { if (iMoodRepository.Get(mood.id) == null) { iMoodRepository.Update(mood); } PlaylistMood newPlaylistMood = new PlaylistMood() { moodId = mood.id, }; iPlaylistMoodRepository.Update(newPlaylistMood); } } if (value.songs != null) { foreach (Song song in value.songs) { if (iSongRepository.Get(song.id) == null) { iSongRepository.Update(song); } SongPlaylist newSongPlaylist = new SongPlaylist() { songId = song.id }; iSongPlaylistRepository.Update(newSongPlaylist); } } iPlaylistRepository.Update(model); }
/// <summary> /// resolveGeners method. /// resolve the generes from a given playlist /// </summary> /// <param name="playList">playlist</param> public void resolveGenres(SongPlaylist playList) { bool flag = true; foreach (Song item in playList.Songs) { foreach (ExtensionInfo ex in CurrentGeners) { if (ex.Extension.Equals(item.Artist.Genre)) { flag = false; break; } } if (flag) { CurrentGeners.Add(new ExtensionInfo(item.Artist.Genre, 0)); } flag = true; } }
// // GET: /Playlist/{songId}/{playlistId} public ActionResult Add(int songId, int playlistId) { Playlists playlist = db.Playlists.Find(playlistId); if (db.Songs.Find(songId) == null || CurrentUser == null || playlist == null || playlist.UserId != CurrentUser.UserId || playlist.SongsInPlaylist.Where(s => s.SongId == songId).Count() > 0) { return(HttpNotFound()); } int next = playlist.SongsInPlaylist.Count > 0 ? playlist.SongsInPlaylist.Max(p => p.Order) + 1 : 1; SongPlaylist songPlaylist = new SongPlaylist { SongId = songId, PlaylistId = playlistId, Order = next }; db.SongPlaylist.Add(songPlaylist); db.SaveChanges(); db.Entry(songPlaylist).Reference(s => s.SongInfo).Load(); db.Entry(songPlaylist).Reference(s => s.Playlist).Load(); return(View(songPlaylist)); }
/// <summary> /// check what tympo types in the songs the are in the current playList. /// </summary> /// <param name="playList">SongPlaylist</param> private void resolveTempo(SongPlaylist playList) { bool flag = true; foreach (Song item in playList.Songs) { string tempo = tempoType(item); foreach (ExtensionInfo ex in TempoList) { if (ex.Extension.Equals(tempo)) { flag = false; break; } } if (flag) { TempoList.Add(new ExtensionInfo(tempo, 0)); } flag = true; } }
public IActionResult AddSongPlaylist(SongPlaylist songPlaylist) { try { //SongPlaylist songPlaylist = new SongPlaylist(); var selected_playlist = Request.Form["selected_playlist"]; Playlist playlist = _context.Playlist.Find(Int32.Parse(selected_playlist)); var selected_song = Request.Form["songId"]; Song song = _context.Song.Find(Int32.Parse(selected_song)); songPlaylist.PlaylistId = playlist.PlaylistId; songPlaylist.SongId = song.SongId; _context.Add(songPlaylist); _context.SaveChanges(); } catch { } Index(); return(View("Index")); }
public async Task <ActionResult <dynamic> > PostYoutubeSong(YoutubeLink youtubeLink) { var SongCount = _context.TSongs.ToList <YoutubeSong>().Count; var PlaylistCount = _playlistContext.TPlaylist.ToList <YoutubePlaylist>().Count; var SongPlaylistCount = _songPlaylistContext.TSongPlaylist.ToList <SongPlaylist>().Count; // This gets the YoutubeVideo object and downloads the mp3 _youtube = new Youtube(youtubeLink.Url, @"C:\Users\nsedler\source\repos\WebApplication3\WebApplication3\Files\"); Tuple <Video, Playlist> VideoPlaylist = await _youtube.GetYoutubeVideoAsync(); await _youtube.DownloadYoutubeVideoAsync(); //Sets the Songs fields YoutubeSong _song = new YoutubeSong(); if (VideoPlaylist.Item1 != null) { _song = new YoutubeSong(); var video = VideoPlaylist.Item1; _song.Title = video.Title; _song.Length = video.Duration.Ticks; _song.Url = $"https://localhost:44370/StaticSongs/{video.Title}.mp3"; _song.Id = SongCount + 1; _context.TSongs.Add(_song); await _context.SaveChangesAsync(); } else { YoutubePlaylist YoutubePlaylist = new YoutubePlaylist(); var Playlist = await _YoutubeClient.Playlists.GetAsync(VideoPlaylist.Item2.Id); YoutubePlaylist.Name = Playlist.Title; YoutubePlaylist.Id = PlaylistCount + 1; _playlistContext.TPlaylist.Add(YoutubePlaylist); await _playlistContext.SaveChangesAsync(); await foreach (var video in _YoutubeClient.Playlists.GetVideosAsync(VideoPlaylist.Item2.Id)) { _song = new YoutubeSong(); _song.Title = video.Title; _song.Length = video.Duration.Ticks; _song.Url = $"https://localhost:44370/StaticSongs/{video.Title}.mp3"; _song.Id = SongCount + 1; _context.TSongs.Add(_song); await _context.SaveChangesAsync(); SongPlaylist SongPlaylist = new SongPlaylist(); SongPlaylist.Id = SongPlaylistCount + 1; SongPlaylist.SongId = _song.Id; SongPlaylist.PlaylistId = YoutubePlaylist.Id; _songPlaylistContext.TSongPlaylist.Add(SongPlaylist); await _songPlaylistContext.SaveChangesAsync(); SongPlaylistCount++; SongCount++; } return(CreatedAtAction("GetYoutubeSong", new { id = YoutubePlaylist.Id }, YoutubePlaylist)); } return(CreatedAtAction("GetYoutubeSong", new { id = _song.Id }, _song)); }
public async Task AddSongPlaylistRelation(SongPlaylist songPlaylistRelation) { await SQLiteNetExtensionsAsync.Extensions.WriteOperations.InsertWithChildrenAsync(_connection, songPlaylistRelation, false); }
public SongPlaylist Delete(int id) { SongPlaylist model = iSongPlaylistRepository.Get(id); return(iSongPlaylistRepository.Delete(model)); }
/// <summary> /// ConvertFromJson method. /// convert the jarray token's into appropriate /// parameters, in this case - playlist /// </summary> /// <param name="arr"></param> public void ConvertFromJson(JArray arr) { Playlist = JsonConvert.DeserializeObject <SongPlaylist>(arr[0].ToString()); }
public SongPlaylist Update(SongPlaylist songPlaylist) { _context.Entry(songPlaylist).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(songPlaylist); }