mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 00:05:53 +01:00
51 lines
1.0 KiB
ObjectPascal
51 lines
1.0 KiB
ObjectPascal
unit RenderSampleControllerU;
|
|
|
|
interface
|
|
|
|
uses
|
|
MVCFramework, MVCFramework.Commons, ObjectsMappers;
|
|
|
|
type
|
|
|
|
[MVCPath('/')]
|
|
TRenderSampleController = class(TMVCController)
|
|
public
|
|
[MVCHTTPMethod([httpGet])]
|
|
[MVCPath('/customers')]
|
|
[MVCProduces('application/json')]
|
|
procedure GetCustomers(CTX: TWebContext);
|
|
|
|
[MVCHTTPMethod([httpGet])]
|
|
[MVCPath('/customers')]
|
|
[MVCProduces('text/xml')]
|
|
procedure GetCustomersXML(CTX: TWebContext);
|
|
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
System.SysUtils, BusinessObjectsU, Data.DBXJSON, WebModuleU;
|
|
|
|
{ TRoutingSampleController }
|
|
|
|
procedure TRenderSampleController.GetCustomers(CTX: TWebContext);
|
|
var
|
|
wm: TWebModule1;
|
|
begin
|
|
wm := GetCurrentWebModule as TWebModule1;
|
|
wm.qryCustomers.Open;
|
|
Render(wm.qryCustomers);
|
|
end;
|
|
|
|
procedure TRenderSampleController.GetCustomersXML(CTX: TWebContext);
|
|
var
|
|
wm: TWebModule1;
|
|
begin
|
|
wm := GetCurrentWebModule as TWebModule1;
|
|
wm.qryCustomers.Open;
|
|
Render(wm.qryCustomers);
|
|
end;
|
|
|
|
end.
|