2013-11-10 01:03:53 +01:00
|
|
|
unit BusinessObjectsU;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
2016-11-27 23:17:20 +01:00
|
|
|
uses
|
2017-04-20 23:48:50 +02:00
|
|
|
MVCFramework.Serializer.Commons;
|
2016-11-27 23:17:20 +01:00
|
|
|
|
2013-11-10 01:03:53 +01:00
|
|
|
type
|
2017-04-20 23:48:50 +02:00
|
|
|
[MVCNameCase(ncLowerCase)]
|
2013-11-10 01:03:53 +01:00
|
|
|
TPerson = class
|
|
|
|
private
|
|
|
|
FLastName: String;
|
|
|
|
FDOB: TDate;
|
|
|
|
FFirstName: String;
|
|
|
|
FMarried: boolean;
|
|
|
|
procedure SetDOB(const Value: TDate);
|
|
|
|
procedure SetFirstName(const Value: String);
|
|
|
|
procedure SetLastName(const Value: String);
|
|
|
|
procedure SetMarried(const Value: boolean);
|
|
|
|
public
|
2016-11-27 23:17:20 +01:00
|
|
|
procedure Validate;
|
2013-11-10 01:03:53 +01:00
|
|
|
property FirstName: String read FFirstName write SetFirstName;
|
|
|
|
property LastName: String read FLastName write SetLastName;
|
|
|
|
property DOB: TDate read FDOB write SetDOB;
|
|
|
|
property Married: boolean read FMarried write SetMarried;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2016-11-27 23:17:20 +01:00
|
|
|
uses
|
|
|
|
System.SysUtils;
|
|
|
|
|
2013-11-10 01:03:53 +01:00
|
|
|
{ TPerson }
|
|
|
|
|
|
|
|
procedure TPerson.SetDOB(const Value: TDate);
|
|
|
|
begin
|
|
|
|
FDOB := Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TPerson.SetFirstName(const Value: String);
|
|
|
|
begin
|
|
|
|
FFirstName := Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TPerson.SetLastName(const Value: String);
|
|
|
|
begin
|
|
|
|
FLastName := Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TPerson.SetMarried(const Value: boolean);
|
|
|
|
begin
|
|
|
|
FMarried := Value;
|
|
|
|
end;
|
|
|
|
|
2016-11-27 23:17:20 +01:00
|
|
|
procedure TPerson.Validate;
|
|
|
|
begin
|
|
|
|
if FirstName.Trim.IsEmpty or LastName.Trim.IsEmpty then
|
|
|
|
raise Exception.Create('Invalid person. First name and last name required');
|
|
|
|
end;
|
|
|
|
|
2013-11-10 01:03:53 +01:00
|
|
|
end.
|