Ejemplo n.º 1
0
        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)));
            }
        }
Ejemplo n.º 2
0
        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"));
        }