public async Task <ActionResult <PlaylistViewModel> > Post([FromBody] PodcastEntryViewModel entry) { var podcast = await _podcastRepository.GetAsync(entry.PodcastId); if (podcast == null) { return(NotFound()); } if (string.IsNullOrEmpty(entry.SourceUrl)) { return(BadRequest("SourceUrl is empty")); } var sourceUrl = await _youTubeParser.ConvertUserToChannel(entry.SourceUrl, podcast.AppUserId); var playlist = new Playlist { Podcast = podcast, SourceUrl = sourceUrl }; _playlistRepository.AddOrUpdate(playlist); try { await _unitOfWork.CompleteAsync(); } catch (DbUpdateException ex) { if (ex.InnerException != null && ex.InnerException.Message.Contains("IX_Playlists_SourceUrl")) { return(Conflict("This podcast is already monitoring this playlist")); } return(BadRequest("There was an error adding this playlist")); } BackgroundJob.Enqueue <ProcessPlaylistsJob>(job => job.Execute(playlist.Id, null)); return(_mapper.Map <Playlist, PlaylistViewModel>(playlist)); }