@namespace MidrandBooks.Components @using Microsoft.AspNetCore.Components @using MidrandBooks.Models
@foreach (var cat in Categories) { }
@if (FilteredBooks().Any()) {
@foreach (var book in FilteredBooks()) { }
} else {

No active publications match your search

Try resetting your filters or browsing with different keywords. Direct self-published uploads require moderation prior to live activation.

}
@code { [Parameter] public List Books { get; set; } = new(); [Parameter] public List Categories { get; set; } = new(); [Parameter] public EventCallback OnSelectBook { get; set; } private string SelectedCategory { get; set; } = "All"; private string SearchQuery { get; set; } = string.Empty; private void SelectCategory(string category) { SelectedCategory = category; } private void HandleSearchInput(ChangeEventArgs e) { SearchQuery = e.Value?.ToString() ?? string.Empty; } private IEnumerable FilteredBooks() { var result = Books.Where(b => b.Status == "published"); if (SelectedCategory != "All") { result = result.Where(b => b.Category.Equals(SelectedCategory, StringComparison.OrdinalIgnoreCase)); } if (!string.IsNullOrWhiteSpace(SearchQuery)) { var query = SearchQuery.Trim().ToLower(); result = result.Where(b => b.Title.ToLower().Contains(query) || b.Author.ToLower().Contains(query) || b.Description.ToLower().Contains(query) ); } return result; } }