first commit

This commit is contained in:
2026-02-26 14:04:18 +07:00
parent 57ac80a666
commit 4b7236493f
92 changed files with 4999 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
namespace MyNewProjectName.Contracts.Common
{
// PagedList model to support pagination in API responses
public class PagedList<T>
{
// Items in the current page
public List<T> Items { get; set; } = new List<T>();
// Total count of items across all pages
public int TotalCount { get; set; }
// Current page number
public int PageNumber { get; set; }
// Page size (items per page)
public int PageSize { get; set; }
// Total number of pages
public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize);
// Flag indicating if there is a previous page
public bool HasPreviousPage => PageNumber > 1;
// Flag indicating if there is a next page
public bool HasNextPage => PageNumber < TotalPages;
public PagedList(List<T> items, int totalCount, int pageNumber, int pageSize)
{
Items = items;
TotalCount = totalCount;
PageNumber = pageNumber;
PageSize = pageSize;
}
// Default constructor
public PagedList() { }
}
}

View File

@@ -0,0 +1,19 @@
namespace MyNewProjectName.Contracts.Common
{
// Parameters for handling pagination in requests
public class PaginationParams
{
private const int MaxPageSize = 1000;
private int _pageSize = 50;
// Page number (default is 1)
public int PageNumber { get; set; } = 1;
// Page size with validation to ensure it doesn't exceed MaxPageSize
public int PageSize
{
get => _pageSize;
set => _pageSize = (value > MaxPageSize) ? MaxPageSize : value;
}
}
}

View File

@@ -0,0 +1,21 @@
namespace MyNewProjectName.Contracts.Common
{
// Generic response model for all API endpoints
public class ServiceResponse<T>
{
// Success status of the request
public bool Success { get; set; } = true;
// Response message
public string Message { get; set; } = string.Empty;
// Response data
public T? Data { get; set; }
// Error details if any
public List<string>? Errors { get; set; }
// Field-specific validation errors for frontend form validation
public Dictionary<string, List<string>>? FieldErrors { get; set; }
}
}