public bool RemovePlaylist(LocalPlaylist localPlaylist) { var result = _playlistRepository.Delete(localPlaylist.Id); RemoveHandleItemsChanged(localPlaylist); return(_playlists.Remove(localPlaylist)); }
public void DeletePlaylist(int playlistId) { using (var uow = UnitOfWorkProvider.Create()) { playlistRepository.Delete(playlistId); uow.Commit(); } }
public ActionResult Delete(Guid id) { Playlist playlist = _playlistRepo.Get(id); if (playlist.ApplicationUserId != this.User.GetUserId()) { return(Unauthorized()); } var folderPath = Path.Combine(_appEnv.WebRootPath, "audio", id.ToString()); if (Directory.Exists(folderPath)) { Task.Run(() => { Directory.Delete(folderPath, true); }); } _playlistRepo.Delete(id); _playlistRepo.SaveChanges(); return(RedirectToAction(nameof(Index))); }
private void Delete() { PlaylistRepository playlistRepository = new PlaylistRepository("playlist.txt"); Console.Clear(); Console.WriteLine("Delete Playlist:"); Console.Write("Playlist Id: "); int playlistId = Convert.ToInt32(Console.ReadLine()); Entity.Playlist playlist = playlistRepository.GetById(playlistId); if (playlist == null) { Console.WriteLine("Plylist not found!"); } else { playlistRepository.Delete(playlist); Console.WriteLine("Playlist deleted successfully."); } Console.ReadKey(true); }
private void Delete() { Console.Clear(); Console.WriteLine("\tDelete Playlist : "); Console.Write("\tPlaylist Id : "); int playlistId = Convert.ToInt32(Console.ReadLine()); Playlist playlist = _playlistRepository.GetById(playlistId); if (playlist == null) { Console.WriteLine("\tPlaylist not found!"); } else { _playlistRepository.Delete(playlist); Console.WriteLine("\n"); Console.WriteLine("\tPlaylist deleted successfully."); } Console.ReadKey(true); }
public void DeleteOnePlaylist() { Playlist playlistDelete = new Playlist { Id = 3, Name = "Rock", Image = "", Description = "Musica para gozar" }; listPlaylist.Add(playlistDelete); var options = new DbContextOptionsBuilder <BetterCalmContext>() .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options; var context = new BetterCalmContext(options); listPlaylist.ForEach(playlist => context.Add(playlist)); context.SaveChanges(); repository = new PlaylistRepository(context); repository.Delete(playlistDelete); context.Database.EnsureDeleted(); Playlist getPlaylist = repository.Get(3); Assert.AreEqual(null, getPlaylist); }