using Microsoft.Data.SqlClient; using System.Net.Mail; namespace Library.Models; public class RepositoryDetailsPageModel : BasePageModel { public BookData BookData { get; } = null!; public List CategoryPath { init; get; } = new( ); public List Attachments { init; get; } = new( ); // public CategoryItemData CategoryData { init; get; } = null!; // public PagingData PagingData { init; get; } = null!; public RepositoryDetailsPageModel( SqlConnection? db , int element_id ) : base( db ) { BookData = BookData.WithID( db! , element_id )!; Attachments = AttachmentData.GetList( db! , element_id ); BuildCategoryPath( CategoryTree.FindCategory( BookData.CategoryID ) ); /* 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! ); } }