Initial commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
namespace PowderCoating.Application.DTOs.Common;
|
||||
|
||||
public class GridRequest
|
||||
{
|
||||
public int PageNumber { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 25;
|
||||
public string? SortColumn { get; set; }
|
||||
public string SortDirection { get; set; } = "asc";
|
||||
public string? SearchTerm { get; set; }
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (PageNumber < 1) PageNumber = 1;
|
||||
if (PageSize < 5) PageSize = 5;
|
||||
if (PageSize > 100) PageSize = 100;
|
||||
if (SortDirection?.ToLower() != "desc") SortDirection = "asc";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace PowderCoating.Application.DTOs.Common;
|
||||
|
||||
public class PagedResult<T>
|
||||
{
|
||||
public IEnumerable<T> Items { get; set; } = new List<T>();
|
||||
public int PageNumber { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize);
|
||||
public bool HasPreviousPage => PageNumber > 1;
|
||||
public bool HasNextPage => PageNumber < TotalPages;
|
||||
public int StartIndex => (PageNumber - 1) * PageSize + 1;
|
||||
public int EndIndex => Math.Min(PageNumber * PageSize, TotalCount);
|
||||
public string? SortColumn { get; set; }
|
||||
public string SortDirection { get; set; } = "asc";
|
||||
public string? SearchTerm { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user