MVC (layered variant)

This commit is contained in:
Boris Milašinović
2026-04-26 13:40:03 +02:00
parent 0ee1b22f61
commit 1415005b82
50 changed files with 2130 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
namespace MVC_SimpleCRUD_Layered.Application.Models;
public record PagedList<T>(List<T> Data, PagingInfo PagingInfo);

View File

@@ -0,0 +1,37 @@
namespace MVC_SimpleCRUD_Layered.Application.Models;
public class PagingInfo
{
public int TotalItemsCount { get; set; }
public int FilteredItemsCount { get; set; }
public int ItemsPerPage { get; set; }
public int CurrentPage { get; set; }
public string? Sorts { get; set; }
public string? SearchText { get; set; }
public int TotalPages => Math.Max(1, (int)Math.Ceiling((decimal)FilteredItemsCount / ItemsPerPage));
public bool IsFiltered => !string.IsNullOrWhiteSpace(SearchText);
public string ToggleSort(string propertyName)
{
return string.Equals(Sorts, propertyName, StringComparison.OrdinalIgnoreCase)
? $"-{propertyName}"
: propertyName;
}
public bool IsSortedBy(string propertyName)
{
return string.Equals(Sorts?.TrimStart('-'), propertyName, StringComparison.OrdinalIgnoreCase);
}
public bool IsDescending()
{
return Sorts?.StartsWith("-", StringComparison.Ordinal) == true;
}
}

View File

@@ -0,0 +1,10 @@
namespace MVC_SimpleCRUD_Layered.Application.Models;
public class PagingSettings
{
public const string SectionName = "Paging";
public int PageSize { get; set; } = 20;
public int PageOffset { get; set; } = 5;
}