initial commit
This commit is contained in:
19
Models/BasePageModel.cs
Normal file
19
Models/BasePageModel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace Library.Models;
|
||||
|
||||
public class BasePageModel
|
||||
{
|
||||
public string PageTitle = "";
|
||||
public UserData? UserData = null;
|
||||
|
||||
public CategoryTreeData CategoryTree { init => m_CategoryTree = value; get => m_CategoryTree; }
|
||||
private CategoryTreeData m_CategoryTree = new( );
|
||||
public BasePageModel( SqlConnection? db )
|
||||
{
|
||||
if ( db != null )
|
||||
{
|
||||
m_CategoryTree.LoadCategoryTree( db! );
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Models/ErrorPageModel.cs
Normal file
13
Models/ErrorPageModel.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Library.Models;
|
||||
|
||||
public class ErrorPageModel : BasePageModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
|
||||
public ErrorPageModel( )
|
||||
: base( null )
|
||||
{
|
||||
}
|
||||
}
|
||||
17
Models/PDFViewModel.cs
Normal file
17
Models/PDFViewModel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace Library.Models;
|
||||
|
||||
public class PDFViewModel : BasePageModel
|
||||
{
|
||||
public readonly int PageCount = 4;
|
||||
public string UUID { init; get; } = null!;
|
||||
public string Title { init; get; } = "Áåç çàãëàâèå";
|
||||
|
||||
public PDFViewModel( SqlConnection? db , string uuid , int page_count )
|
||||
: base( db )
|
||||
{
|
||||
PageCount = page_count;
|
||||
UUID = uuid;
|
||||
}
|
||||
}
|
||||
47
Models/RepositoryDetailsPageModel.cs
Normal file
47
Models/RepositoryDetailsPageModel.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Net.Mail;
|
||||
|
||||
namespace Library.Models;
|
||||
|
||||
public class RepositoryDetailsPageModel : BasePageModel
|
||||
{
|
||||
public BookData BookData { get; } = null!;
|
||||
public List<CategoryItemData> CategoryPath { init; get; } = new( );
|
||||
public List<AttachmentData> 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! );
|
||||
}
|
||||
}
|
||||
44
Models/RepositoryPageModel.cs
Normal file
44
Models/RepositoryPageModel.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace Library.Models;
|
||||
|
||||
public class RepositoryPageModel : BasePageModel
|
||||
{
|
||||
public BookListData Books { get; } = new( );
|
||||
public CategoryItemData CategoryData { init; get; } = null!;
|
||||
public List<CategoryItemData> CategoryPath { init; get; } = new( );
|
||||
public PagingData PagingData { init; get; } = null!;
|
||||
|
||||
public RepositoryPageModel( SqlConnection? db , int category_index , int page_index )
|
||||
: base( db )
|
||||
{
|
||||
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! );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
49
Models/SearchPageModel.cs
Normal file
49
Models/SearchPageModel.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
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! );
|
||||
} */
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user