public void RateSong(SongRatingDto rating, string userName) { using (SmartPlayerEntities context = new SmartPlayerEntities()) { UserRepository userRepo = new UserRepository(context); User currentUser = userRepo.GetAll().First(x => x.Email == userName); context.UserSongVotes.Add(new UserSongVote() { Rating = rating.Rating, SongId = rating.SongId, UserId = currentUser.Id }); context.SaveChanges(); } }
public async Task RateSong(SongRatingDto rating) { MusicService service = new MusicService(); var username = this.User.Identity.Name; service.RateSong(rating, username); }