public void DeleteSongTest() { _songService.DeleteSong(_song3Id); _songService.DeleteSong(_song2Id); Assert.IsNull(_songService.GetSong(_song3Id)); Assert.IsNull(_songService.GetSong(_song2Id)); }
public ActionResult Delete(int Id, string returnUrl) { if (UserIsLegit(Id)) { var song = _songService.GetSong(Id); if (song == null) { return(new HttpNotFoundResult()); } _songService.DeleteSong(Id); Services.Notifier.Information(T("Din sang er nu slettet")); return(Redirect(returnUrl)); } else { Services.Notifier.Information(T("Dit brugernavn matcher ikke det, der har uploadet sangen - handling afvist.")); return(Redirect(returnUrl)); } }
public ActionResult <bool> DeleteSong(int id) { try { return(Ok(service.DeleteSong(id))); } catch (NotFoundException ex) { return(NotFound(ex.Message)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public ActionResult Delete(int id) { var song = service.FindSongById(id); if (song == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (song.Uploader.Id != User.Identity.GetUserId() && !User.IsInRole("admin")) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden)); } service.DeleteSong(song); return(RedirectToAction("Index")); }
public async Task <IActionResult> Delete(Int64 id) { try { var song = await _songService.DeleteSong(id); if (song == null) { return(NotFound()); } return(Ok("Deleted Successfully!")); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to delete record!")); } }
public ActionResult SongIndex(FormCollection form) { var viewModel = new SongIndexViewModel { Songs = new List <SongEntry>(), Options = new SongIndexOptions() }; UpdateModel(viewModel); IEnumerable <SongEntry> checkedEntries = viewModel.Songs.Where(s => s.IsChecked); switch (viewModel.Options.BulkAction) { case SongIndexBulkAction.None: break; case SongIndexBulkAction.Open: foreach (SongEntry entry in checkedEntries) { throw new NotImplementedException(); // _songService.OpenSong(entry.Song.Id); } break; case SongIndexBulkAction.Close: foreach (SongEntry entry in checkedEntries) { throw new NotImplementedException(); // _songService.CloseSong(entry.Song.Id); } break; case SongIndexBulkAction.Delete: foreach (SongEntry entry in checkedEntries) { _songService.DeleteSong(entry.Song.Id); } break; default: throw new ArgumentOutOfRangeException("form"); } return(RedirectToAction("SongIndex")); }
public async Task <ActionResult> Delete(int id) { await songService.DeleteSong(id); return(Ok()); }
public void DeleteSong(int songId) { songService.DeleteSong(songId); }
public void DeleteSong(int id) { songService.DeleteSong(id); }
private static void TestSongService() { List <int> list = new List <int>(); songService = Container.Resolve <ISongService>(); clientService = Container.Resolve <IClientService>(); //Create songService.CreateSong(new SongDTO { Name = "Hit The Floor", AlbumID = albumID, CreatorID = clientID, Duration = new TimeSpan(0, 0, 3, 30), IsOfficial = true, }); songService.CreateSong(new SongDTO { Name = "4 Words", AlbumID = albumID, CreatorID = clientID, Duration = new TimeSpan(0, 0, 3, 43), IsOfficial = true, }); songService.CreateSong(new SongDTO { Name = "All These Things I Hate", AlbumID = albumID, CreatorID = clientID2, Duration = new TimeSpan(0, 0, 3, 45), IsOfficial = true, }); //GetSongIdByName songID = songService.GetSongIdByName("Hit The Floor"); int wordsID = songService.GetSongIdByName("4 Words"); songID2 = songService.GetSongIdByName("All These Things I Hate"); list.Add(songID); list.Add(wordsID); list.Add(songID2); Console.WriteLine(list.Count() == 3 ? "ClientService - GetSongIdByName - OK" : "ClientService - GetSongIdByName - FAIL"); //GetSongById SongDTO floor = songService.GetSong(songID); SongDTO words4 = songService.GetSong(wordsID); SongDTO hate = songService.GetSong(songID2); Console.WriteLine(floor.Name == "Hit The Floor" ? "SongService - GetSongById - OK" : "SongService - GetSongById - FAIL"); albumService = Container.Resolve <IAlbumService>(); //AddSong songService.AddSong(floor); songService.AddSong(words4); songService.AddSong(hate); AlbumDTO album = albumService.GetAlbum(albumID); Console.WriteLine(album.SongIDs.Contains(songID) ? "SongService - AddSong - OK" : "SongService - AddSong - FAIL"); //GetAlbumOfSong AlbumDTO album2 = songService.GetAlbumOfSong(songID); Console.WriteLine(album2.ID == albumID ? "SongService - GetAlbumOfSong - OK" : "SongService - GetAlbumOfSong - FAIL"); //TestAlbumServisGetAllSongs Console.WriteLine(album.SongIDs.Count() == 3 ? "AlbumService - TestAlbumServisGetAllSongs - OK" : "AlbumService - TestAlbumServisGetAllSongs - FAIL"); ////ListAllSongs //var songs = songService.ListAllSongs(new SongFilter { AlbumID = albumID }, 1); //Console.WriteLine(songs.TotalResultCount == 3 ? "SongService - TestListAllSongs - OK" : "SongService - TestListAllSongs - FAIL"); //ListAllSongss02 var songs2 = songService.ListAllSongs(); Console.WriteLine(songs2.Count() == 3 ? "SongService - ListAllSongss02 - OK" : "SongService - ListAllSongss02 - FAIL"); //EditSong words4.Name = "Four Words"; songService.EditSong(words4, albumID, words4.ReviewIDs); SongDTO words4FromDB = songService.GetSong(words4.ID); Console.WriteLine(words4FromDB.Name == "Four Words" ? "SongService - TestEditSong - OK" : "SongService - TestEditSong - FAIL"); //DeleteSong songService.DeleteSong(wordsID); try { SongDTO wordsFromDB = songService.GetSong(wordsID); Console.WriteLine("SongService - TestDeleteSong - FAIL"); } catch (NullReferenceException) { Console.WriteLine("SongService - TestDeleteSong - OK"); } //GetCreator ClientDTO creator = genreService.GetCreator(floor.ID); Console.WriteLine(creator.ID == clientID ? "SongService - GetCreator - OK" : "SongService - GetCreator - FAIL"); }