Initial DeepDrft Models Project

- Track Entity & DTO
 - Paging models
This commit is contained in:
2025-08-30 21:43:15 -04:00
parent c86632e979
commit aac0004e03
5 changed files with 99 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
namespace DeepDrftModels.Models;
public class PagedResult<T>
{
public IEnumerable<T> Items { get; set; } = new List<T>();
public int TotalCount { get; set; }
public int Page { get; set; }
public int PageSize { get; set; }
public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
public bool HasNextPage => Page < TotalPages;
public bool HasPreviousPage => Page > 1;
public PagedResult()
{
}
public static PagedResult<T> From<TOther>(PagedResult<TOther> other, IEnumerable<T> items)
{
return new PagedResult<T>()
{
Items = items.ToList(),
Page = other.Page,
PageSize = other.PageSize,
TotalCount = other.TotalCount,
};
}
public PagedResult(IEnumerable<T> items, int totalCount, int page, int pageSize)
{
Items = items.ToList() ?? new List<T>();
TotalCount = totalCount;
Page = page;
PageSize = pageSize;
}
}