public void Put(PlaylistRating playlistRating) { var ratingToEdit = _repo.PlaylistRatings.GetPlaylistRating(playlistRating.PlaylistRatingId); ratingToEdit.PlaylistUrl = playlistRating.PlaylistUrl; ratingToEdit.PlaylistRatingId = playlistRating.PlaylistRatingId; ratingToEdit.Rating = playlistRating.Rating; _repo.PlaylistRatings.Update(ratingToEdit); _repo.Save(); }
public async Task AddPlaylistRatingAsync(PlaylistRating playlistRating) { string url = _config.GetValue <string>("ApiHostUrl:BaseUrl"); url += "api/PlaylistRating"; var json = JsonConvert.SerializeObject(playlistRating); var data = new StringContent(json, Encoding.UTF8, "application/json"); using var client = new HttpClient(); HttpResponseMessage response = await client.PostAsync(url, data); }
public void Post(PlaylistRating playlistRating) { var newPlayListRating = new PlaylistRating { PlaylistUrl = playlistRating.PlaylistUrl, Rating = playlistRating.Rating, PlaylistRatingId = playlistRating.PlaylistRatingId }; _repo.PlaylistRatings.CreatePlaylistRating(newPlayListRating); _repo.Save(); }
public async Task <ActionResult> RecommendMusic(NumberRating numberRating) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var moodTracker = await _databaseService.GetMoodTrackerAsync(userId); var playlistRating = new PlaylistRating { PlaylistUrl = numberRating.Url, MoodTrackerId = moodTracker.MoodTrackerId }; if (numberRating.Rating >= 5) { playlistRating.Rating = true; } else { playlistRating.Rating = false; } await _databaseService.AddPlaylistRatingAsync(playlistRating); return(RedirectToAction(nameof(Index))); }