Cliente entity represents a customer in the SGRH system. It stores essential personal information and enforces validation rules to ensure data integrity.
Overview
Cliente is a sealed entity that inherits from EntityBase. It maintains customer details including national identification, name, contact information, and provides methods for updating customer data with proper validation.
Namespace: SGRH.Domain.Entities.Clientes
Source: ~/workspace/source/SGRH.Domain/Entities/Clientes/Cliente.cs
Properties
Unique identifier for the customer (primary key).
National identification number (e.g., cedula). Maximum length: 20 characters.
Customer’s first name. Maximum length: 100 characters.
Customer’s last name. Maximum length: 100 characters.
Customer’s email address. Maximum length: 100 characters.
Customer’s phone number. Maximum length: 20 characters.
Constructor
Parameters
- nationalId: National ID (max 20 chars, required)
- nombreCliente: First name (max 100 chars, required)
- apellidoCliente: Last name (max 100 chars, required)
- email: Email address (max 100 chars, required)
- telefono: Phone number (max 20 chars, required)
Validations
All parameters are validated usingGuard.AgainstNullOrWhiteSpace to ensure:
- Values are not null or empty
- Values do not exceed maximum length constraints
Example
Methods
ActualizarDatos
Note: The
NationalId cannot be changed after creation. Only name, email, and phone can be updated.Parameters
- nombreCliente: Updated first name (max 100 chars)
- apellidoCliente: Updated last name (max 100 chars)
- email: Updated email address (max 100 chars)
- telefono: Updated phone number (max 20 chars)
Example
Business Rules
Validation Rules
Validation Rules
All string properties are validated to ensure:
- Non-empty values: No null or whitespace-only strings
- Maximum length enforcement: Each field has specific length constraints
- Immutable National ID: The national ID cannot be changed after creation
ValidationException with descriptive error messages.Identity
Identity
The entity uses
ClienteId as its primary key, implemented via the GetKey() method from EntityBase.Usage in Application
TheCliente entity is typically used in:
- Reservation System: Linked to reservations via
ClienteId - Customer Management: CRUD operations for customer records
- Reporting: Customer analytics and history
Related Entities
- Reserva: References
ClientethroughClienteId(see Reserva)