mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 00:05:53 +01:00
54c82554e6
MVCFramework.Controllers.CacheController.pas
36 lines
854 B
ObjectPascal
36 lines
854 B
ObjectPascal
unit CommonsU;
|
|
|
|
interface
|
|
|
|
uses
|
|
System.SysUtils, System.Classes;
|
|
|
|
type
|
|
EWrongPage = class(Exception)
|
|
|
|
end;
|
|
|
|
procedure GetLimitByPage(const APage: Integer; out StartRec: Integer; out EndRec: Integer);
|
|
procedure MergePaginationMetaInfos(AURLFormat: String; AHeaders: TStrings; ACurrPage: Integer);
|
|
|
|
implementation
|
|
|
|
procedure MergePaginationMetaInfos(AURLFormat: String; AHeaders: TStrings; ACurrPage: Integer);
|
|
begin
|
|
AHeaders.Values['dmvc-next-page'] :=
|
|
Format(AURLFormat, [ACurrPage + 1]);
|
|
if ACurrPage > 1 then
|
|
AHeaders.Values['dmvc-prev-page'] :=
|
|
Format(AURLFormat, [ACurrPage - 1]);
|
|
end;
|
|
|
|
procedure GetLimitByPage(const APage: Integer; out StartRec: Integer; out EndRec: Integer);
|
|
begin
|
|
if APage < 1 then
|
|
raise EWrongPage.Create('Page must be greater than 0');
|
|
EndRec := APage * 10;
|
|
StartRec := EndRec - 9;
|
|
end;
|
|
|
|
end.
|