2015-12-02 04:14:15 +01:00
|
|
|
unit RESTControllerCustomerU;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-01-18 21:53:53 +01:00
|
|
|
MVCFramework, MVCFramework.Commons, WSHelperCustomersU;
|
2015-12-02 04:14:15 +01:00
|
|
|
|
|
|
|
type
|
2017-01-18 21:53:53 +01:00
|
|
|
|
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.
|