Skip to content

Commit

Permalink
Platform: implement removing shows from platform
Browse files Browse the repository at this point in the history
  • Loading branch information
yelizsevinc committed Aug 6, 2024
1 parent 10380f1 commit 34f6a29
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion CineStream/Components/Pages/Platform/PlatformDetails.razor
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
@foreach (var show in platformShows)
{
<ul>
<li>@show.Title</li>
<li class=my-1>
<Button Icon="times" Variant="Danger" OnClick="@(e => RemoveShow(show.Title))"></Button> @show.Title
</li>
</ul>
}
}
Expand Down Expand Up @@ -200,4 +202,18 @@
Console.Error.WriteLine($"Error deleting platform: {ex.Message}");
}
}

private async Task RemoveShow(string showTitle)
{
// Remove show from platform
using var context = await DbFactory.CreateDbContextAsync();
var show = await context.Shows!.FirstOrDefaultAsync(c => c.Title == showTitle);
var platformShow = await context.PlatformShows!.FirstOrDefaultAsync(c => c.ShowId == show.ShowId && c.PlatformId == platform.PlatformId);
context.PlatformShows!.Remove(platformShow);
await context.SaveChangesAsync();
// Reload platform shows
platformShows.Clear();
await LoadPlatformShowsAsync(context);

}
}

0 comments on commit 34f6a29

Please sign in to comment.