diff --git a/samples/functional_actions_showcase/ControllerU.pas b/samples/functional_actions_showcase/ControllerU.pas index b73f97ee..42f1663f 100644 --- a/samples/functional_actions_showcase/ControllerU.pas +++ b/samples/functional_actions_showcase/ControllerU.pas @@ -7,14 +7,12 @@ uses System.Generics.Collections, Data.DB, JsonDataObjects, System.Rtti; type - [MVCNameCase(ncCamelCase)] TPersonRec = record FirstName, LastName: String; Age: Integer; class function Create: TPersonRec; static; end; - [MVCNameCase(ncCamelCase)] TPerson = class private fAge: Integer; @@ -34,6 +32,8 @@ type function GetSum(const A, B: Integer): Integer; [MVCPath('/sumsasfloat/($A)/($B)')] function GetSumAsFloat(const A, B: Extended): Extended; + [MVCPath('/booleans/($A)/($B)')] + function GetOrTruthTable(const A, B: Boolean): Boolean; [MVCPath('/string/($A)/($B)')] function GetConcatAsString(const A, B: String): String; @@ -67,6 +67,15 @@ type [MVCPath('/headers')] function GetWithCustomHeaders: TObjectList; + { exceptions } + [MVCPath('/exception1')] + function GetMVCException: Integer; + + [MVCPath('/exception2')] + function GetGeneralException: Integer; + + + { using IMVCResponse and Response Methods} [MVCPath('/mvcresponse/message')] function GetMVCResponseSimple: IMVCResponse; @@ -140,7 +149,10 @@ begin end; end; - +function TMyController.GetMVCException: Integer; +begin + raise EMVCException.Create(HTTP_STATUS.NotFound, 'Resource not found'); +end; function TMyController.GetMVCResponseNoBody: IMVCResponse; begin @@ -226,6 +238,11 @@ begin Result := OKResponse; end; +function TMyController.GetOrTruthTable(const A, B: Boolean): Boolean; +begin + Result := A or B; +end; + function TMyController.GetMVCResponseWithJSON: IMVCResponse; begin Result := OKResponse(StrToJSONObject('{"name":"Daniele","surname":"Teti"}')); @@ -292,6 +309,11 @@ begin Result := A + B; end; +function TMyController.GetGeneralException: Integer; +begin + raise Exception.Create('This is a general exception'); +end; + function TMyController.GetWithCustomHeaders: TObjectList; begin Result := TObjectList.Create; diff --git a/samples/functional_actions_showcase/function_actions_showcase.dpr b/samples/functional_actions_showcase/function_actions_showcase.dpr index 89675d3e..f8053bd7 100644 --- a/samples/functional_actions_showcase/function_actions_showcase.dpr +++ b/samples/functional_actions_showcase/function_actions_showcase.dpr @@ -16,7 +16,7 @@ uses IdHTTPWebBrokerBridge, ControllerU in 'ControllerU.pas', WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule}, - MainDMU in 'MainDMU.pas' {dmMain: TDataModule}; + MainDMU in 'MainDMU.pas', MVCFramework.Serializer.Commons {dmMain: TDataModule}; {$R *.res} @@ -54,6 +54,7 @@ begin // When MVCSerializeNulls = True empty nullables and nil are serialized as json null. // When MVCSerializeNulls = False empty nullables and nil are not serialized at all. MVCSerializeNulls := True; + MVCNameCaseDefault := TMVCNameCase.ncCamelCase; try if WebRequestHandler <> nil then