2015-12-02 04:14:15 +01:00
|
|
|
unit RESTControllerCustomerU;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
MVCFramework, WSHelperCustomersU;
|
|
|
|
|
|
|
|
type
|
2015-12-04 16:55:11 +01:00
|
|
|
[MVCPath('/')]
|
2015-12-02 04:14:15 +01:00
|
|
|
TControllerCustomer = class(TMVCController)
|
|
|
|
private
|
|
|
|
FWSHelperCustomers: TWSHelperCustomers;
|
|
|
|
protected
|
|
|
|
procedure OnBeforeAction(Context: TWebContext; const AActionNAme: string;
|
|
|
|
var Handled: Boolean); override;
|
|
|
|
procedure OnAfterAction(Context: TWebContext;
|
|
|
|
const AActionNAme: string); override;
|
|
|
|
|
|
|
|
public
|
2015-12-04 16:55:11 +01:00
|
|
|
[MVCPath('/customers')]
|
2015-12-02 04:14:15 +01:00
|
|
|
[MVCHTTPMethod([httpGET])]
|
|
|
|
procedure GetCustomers(ctx: TWebContext);
|
|
|
|
|
2015-12-04 16:55:11 +01:00
|
|
|
[MVCPath('/')]
|
|
|
|
[MVCHTTPMethod([httpGET])]
|
|
|
|
procedure Index(ctx: TWebContext);
|
|
|
|
|
2015-12-02 04:14:15 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
System.SysUtils, BOCustomersU;
|
|
|
|
|
|
|
|
procedure TControllerCustomer.OnBeforeAction(Context: TWebContext;
|
|
|
|
const AActionNAme: string; var Handled: Boolean);
|
|
|
|
begin
|
|
|
|
FWSHelperCustomers := TWSHelperCustomers.Create;
|
|
|
|
end;
|
|
|
|
|
2015-12-04 16:55:11 +01:00
|
|
|
procedure TControllerCustomer.Index(ctx: TWebContext);
|
|
|
|
begin
|
|
|
|
Redirect('/index.html');
|
|
|
|
end;
|
|
|
|
|
2015-12-02 04:14:15 +01:00
|
|
|
procedure TControllerCustomer.OnAfterAction(Context: TWebContext;
|
|
|
|
const AActionNAme: string);
|
|
|
|
begin
|
|
|
|
FreeAndNil(FWSHelperCustomers);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TControllerCustomer.GetCustomers(ctx: TWebContext);
|
|
|
|
begin
|
|
|
|
Render<TCustomer>(FWSHelperCustomers.GetCustomers);
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|