delphimvcframework/samples/renders/RenderSampleControllerU.pas
daniele.teti dff01d4dd2
2013-11-10 00:03:53 +00:00

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.