internal string Delete(int id) { Artist data = GetById(id); _repo.Delete(id); return("delorted"); }
public ActionResult Delete(int id) { _artistsRepository.Delete(id); TempData["Message"] = "Your artist was successfully deleted!"; return(RedirectToAction("Index")); }
public void DeleteArtist() { ViewArtists(); Console.WriteLine(); InputId: Console.Write("Enter artist id to delete: "); int deleteId; bool isInt = int.TryParse(Console.ReadLine(), out deleteId); while (isInt == false) { Console.WriteLine("IDs can only be integer numbers. Try again!!"); Console.ReadKey(true); goto InputId; } ArtistsRepository artistsRepo = new ArtistsRepository(Constants.ArtistsPath); Artist artist = artistsRepo.GetAll(a => a.Id == deleteId).FirstOrDefault(); if (artist == null) { Console.WriteLine("No artist with that Id exists in the system yet!"); Console.ReadKey(true); return; } SongsArtistsRepository songsArtistsRepo = new SongsArtistsRepository(Constants.SongsArtistsPath); List <SongsArtists> songsArtistsEntities = songsArtistsRepo.GetAll(sae => sae.ArtistId == deleteId); SongsRepository songsRepo = new SongsRepository(Constants.SongsPath); List <Song> songs = new List <Song>(); foreach (SongsArtists songsArtistsEntity in songsArtistsEntities) { Song song = songsRepo.GetAll(s => s.Id == songsArtistsEntity.SongId).FirstOrDefault(); songs.Add(song); } PlaylistsSongsRepository playlistsSongsRepo = new PlaylistsSongsRepository(Constants.PlaylistsSongsPath); List <PlaylistsSongs> playlistsSongsEntities = new List <PlaylistsSongs>(); foreach (SongsArtists songsArtistsEntity in songsArtistsEntities) { PlaylistsSongs playlistSongEntity = playlistsSongsRepo.GetAll(pse => pse.SongId == songsArtistsEntity.SongId).FirstOrDefault(); playlistsSongsEntities.Add(playlistSongEntity); } foreach (PlaylistsSongs playlistsSongsEntity in playlistsSongsEntities) { playlistsSongsRepo.Delete(playlistsSongsEntity); } foreach (Song song in songs) { songsRepo.Delete(song); } artistsRepo.Delete(artist); Console.WriteLine("Artist deleted successfully!"); Console.ReadKey(true); }
internal void DeleteArtist(int id) { GetById(id); _repo.Delete(id); }