public async Task Like([FromBody] MusicPreference likedSong)
        {
            var userId      = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var userProfile = _context.UserProfiles.Where(u => u.UserId.Equals(userId)).Single();

            likedSong.UserId = userProfile.UserProfileId;

            await _context.MusicPreferences.AddAsync(likedSong);

            await _context.SaveChangesAsync();
        }
Beispiel #2
0
        public async Task Create(string artist, string songName, string genre)
        {
            MusicPreference preference = new MusicPreference();

            preference.SongName   = songName;
            preference.ArtistName = artist;
            preference.Genre      = genre;
            var userid = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var user   = await _context.UserProfiles.Where(x => x.UserId == userid).FirstOrDefaultAsync();

            preference.UserId = user.UserProfileId;
            preference.User   = user;
            await _context.MusicPreferences.AddAsync(preference);

            await _context.SaveChangesAsync();
        }