public IActionResult DeleteArtist(int id) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; ArtistT foundArtist = new ArtistT(); try { foundArtist.UserId = userId; foundArtist.Apiid = id; foundArtist = _musicDb.ArtistT.Where(x => x.Apiid == id).First(); _musicDb.ArtistT.Remove(foundArtist); _musicDb.SaveChanges(); return(RedirectToAction(nameof(DisplayArtistFavorites))); } catch { return(RedirectToAction(nameof(DisplayArtistFavorites))); } }
public IActionResult SaveFavoriteArtist(int id) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; ArtistT foundArtist = new ArtistT(); try { foundArtist = _musicDb.ArtistT.Where(x => x.Apiid == id).First(); } catch { foundArtist.UserId = userId; foundArtist.Apiid = id; _musicDb.ArtistT.Add(foundArtist); _musicDb.SaveChanges(); return(RedirectToAction("DisplayArtistFavorites")); } return(View("MusicIndex")); }