diff --git a/src/Services/Podcasts/Podcast.Infrastructure/Data/PodcastDbContext.cs b/src/Services/Podcasts/Podcast.Infrastructure/Data/PodcastDbContext.cs index 1e9df17..9fd903c 100644 --- a/src/Services/Podcasts/Podcast.Infrastructure/Data/PodcastDbContext.cs +++ b/src/Services/Podcasts/Podcast.Infrastructure/Data/PodcastDbContext.cs @@ -28,7 +28,6 @@ public class PodcastDbContext : DbContext { modelBuilder.Entity().HasData(Seed.Feeds); modelBuilder.Entity().HasData(Seed.Categories); - modelBuilder.Entity().HasQueryFilter(show => _showClient.CheckLink(show.Link).Result); modelBuilder.Entity().HasData(Seed.FeedCategories); modelBuilder.Entity().HasKey(prop => new { prop.FeedId, prop.CategoryId }); base.OnModelCreating(modelBuilder); diff --git a/src/Services/Podcasts/Podcast.MinimalAPI/Routes/ShowsApi.cs b/src/Services/Podcasts/Podcast.MinimalAPI/Routes/ShowsApi.cs index 9f7068f..109f49b 100644 --- a/src/Services/Podcasts/Podcast.MinimalAPI/Routes/ShowsApi.cs +++ b/src/Services/Podcasts/Podcast.MinimalAPI/Routes/ShowsApi.cs @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore; using Podcast.API.Models; using Podcast.Infrastructure.Data; +using Podcast.Infrastructure.Http; namespace Podcast.API.Routes; @@ -14,7 +15,7 @@ public static class ShowsApi return group; } - public static async ValueTask>> GetAllShows(int limit, string? term, Guid? categoryId, CancellationToken cancellationToken, PodcastDbContext podcastDbContext) + public static async ValueTask>> GetAllShows(int limit, string? term, Guid? categoryId, CancellationToken cancellationToken, PodcastDbContext podcastDbContext, ShowClient showClient) { var showsQuery = podcastDbContext.Shows.Include(show => show.Feed!.Categories) .ThenInclude(x => x.Category) @@ -32,7 +33,9 @@ public static class ShowsApi .Take(limit) .Select(x => new ShowDto(x)) .ToListAsync(cancellationToken); - return TypedResults.Ok(shows); + var showsWithValidLinks = + shows.Where(show => !showClient.CheckLink(show.Link).Result).ToList(); + return TypedResults.Ok(showsWithValidLinks); }