Files
LibraryWeb/Models/SearchPageModel.cs
2026-08-04 14:41:21 +03:00

50 lines
1.5 KiB
C#

using Microsoft.Data.SqlClient;
namespace Library.Models;
public class SearchPageModel : BasePageModel
{
public BookListData Books { get; } = new( );
public PagingData PagingData { init; get; } = null!;
public string SearchTerm { init; get; } = null!;
public SearchPageModel( SqlConnection? db , string term , int page )
: base( db )
{
SearchTerm = term;
Books.LoadSearch( db! , term , page , 20 );
int books_in_search = BookListData.GetTotalSearchCount( db! , term );
PagingData = new PagingData( "/Search?q=" + term + "&page=" , page , books_in_search , 20 );
/* CategoryData = LookupCategoryData( category_index );
BuildCategoryPath( CategoryTree.FindCategory( CategoryData.ParentID ) );
Books.LoadCategory( db! , CategoryData.ID , page_index , 20 );
int books_in_category = BookListData.GetCategoryCount( db! , category_index );
PagingData = new PagingData( "/Repository/" + category_index + "?page=" , page_index , books_in_category , 20 );*/
}
/* private CategoryItemData LookupCategoryData( int category_index )
{
CategoryItemData? category_data = CategoryTree.FindCategory( category_index );
if ( category_data != null )
return category_data!;
return CategoryTree.FindCategory( CategoryTree.GetRootID( ) )!;
}
private void BuildCategoryPath( CategoryItemData? item )
{
if ( item == null )
return;
CategoryItemData? parent_item = CategoryTree.FindCategory( item!.ParentID );
if ( parent_item != null )
BuildCategoryPath( parent_item );
CategoryPath.Add( item! );
} */
}