Files
PowderCoatingLogix/src/PowderCoating.Application/DTOs/Common/PagedResult.cs
T
spouliot edd7389d7d Refactor: extract shared helpers, fix field drift, add assembly services
- IJobItemAssemblyService / IQuotePricingAssemblyService: centralize job item
  and quote pricing construction that was duplicated across create, rework copy,
  and quote-to-job conversion paths
- BlobFileHelper: single ValidateUpload/GetContentType/SanitizeFileName used by
  6 blob services (JobPhoto, QuotePhoto, ProfilePhoto, CompanyLogo, Equipment,
  Catalog) and BillsController + ExpensesController, removing 8 private copies
- PagedResult<T>.From(): static factory eliminates 6-line boilerplate in 11
  controllers (Appointments, Customers, Equipment, Inventory, Invoices, Jobs,
  Maintenance, CompanyUsers, PlatformUsers, Quotes, Vendors)
- AccountingDropdownHelper: single LoadAsync() call replaces duplicate
  vendor/account/job queries in BillsController and ExpensesController
- JobTemplateItem: add IsSalesItem + Sku fields with migration; propagate
  through JobTemplatesController snapshot copy and GetTemplatesJson projection,
  and JobsController template-application path
- Test assertions updated for standardized BlobFileHelper error messages

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09 22:12:33 -04:00

34 lines
1.4 KiB
C#

namespace PowderCoating.Application.DTOs.Common;
public class PagedResult<T>
{
public IEnumerable<T> Items { get; set; } = new List<T>();
/// <summary>
/// Creates a PagedResult populated from a GridRequest, avoiding repetitive property
/// assignments across every Index action. SortColumn, SortDirection, and SearchTerm
/// are copied from the grid so the model carries full state for view binding.
/// </summary>
public static PagedResult<T> From(GridRequest grid, IEnumerable<T> items, int totalCount) => new()
{
Items = items,
PageNumber = grid.PageNumber,
PageSize = grid.PageSize,
TotalCount = totalCount,
SortColumn = grid.SortColumn,
SortDirection = grid.SortDirection,
SearchTerm = grid.SearchTerm
};
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; }
}