delphimvcframework/samples/routingsample/RoutingSampleControllerU.pas
daniele.teti 5220f02ca0
2013-11-09 09:32:54 +00:00

41 lines
887 B
ObjectPascal

unit RoutingSampleControllerU;
interface
uses
MVCFramework, MVCFramework.Commons;
type
[MVCPath('/')]
TRoutingSampleController = class(TMVCController)
public
[MVCHTTPMethod([httpGet])]
[MVCPath('/($searchtext)/($page)')]
[MVCProduce('text/plain')]
procedure SearchCustomers(CTX: TWebContext);
end;
implementation
uses
System.SysUtils;
{ TRoutingSampleController }
procedure TRoutingSampleController.SearchCustomers(CTX: TWebContext);
var
search: string;
p: Integer;
orderby: string;
begin
search := CTX.Request.Params['searchtext'];
p := CTX.Request.ParamsAsInteger['page'];
orderby := '';
if CTX.Request.QueryStringParamExists('order') then
orderby := CTX.Request.QueryStringParam('order');
Render(Format('SEARCHTEXT: "%s", PAGE: %d, ORDERBYFIELD: "%s"', [search, p, orderby]));
end;
end.