public IActionResult GetPrivate(string privateSongIdString) { if (privateSongIdString == null || !Guid.TryParse(privateSongIdString, out Guid privateSongId)) { return(NotFound()); } //Search for the user and include all the necessary info: MyUser user = _context.Users.Include(x => x.PrivateSongs) .ThenInclude(x => x.Song) .ThenInclude(y => y.Video) .FirstOrDefault(x => x.UserName == HttpContext.User.Identity.Name); if (user == null) { return(NotFound()); } //Search for the song in user's private songs PrivateSong privateSong = user.PrivateSongs.FirstOrDefault(x => x.PrivateSongId == privateSongId); if (privateSong == null) { return(NotFound()); } PlayableSongVM playableSong = new PlayableSongVM(privateSong.Song); return(Ok(playableSong)); }
public IActionResult GetPublic(string songIdString) { // Validate string id as a valid GUID id: if (!Guid.TryParse(songIdString, out Guid songId)) { return(BadRequest()); } // Search for the song, include all necessary info Song song = _context.Songs .Include(x => x.Video) .Include(y => y.PublicSong) .ThenInclude(x => x.Album) .ThenInclude(x => x.Artist) .Include(y => y.PrivateSong) .FirstOrDefault(x => x.SongId == songId); if (song == null) { return(NotFound()); } PlayableSongVM playalbeSong = new PlayableSongVM(song); return(Ok(playalbeSong)); }
internal static bool CheckIfPlayableSongVmForPrivateSongMatchesDb(PlayableSongVM responseObject, string requestPrivateSongId) { return(CompareResultWithDB <PlayableSongVM>( $"execute GetPlayableSongVMForPrivateSongBM '{requestPrivateSongId}'", responseObject)); }