Overview
TheCN_Clientes class provides business logic operations for managing clients in the sports courts reservation system. It handles client CRUD operations and includes null-safety checks when retrieving data from the data layer.
Namespace: capa_negocio
Dependencies:
capa_entidad.CE_Clientes- Client entity modelcapa_dato.CD_Clientes- Data access layer for clients
Class Definition
Methods
Listar
Retrieves a list of all clients from the database with null-safety handling.A list of all clients in the system. Returns an empty list if no clients are found.
CD_Clientes.ListarClientes() which executes the stored procedure SP_Clientes_List. Includes null-safety check to return an empty list if the data layer returns null.
Insertar
Adds a new client to the system.The client object containing:
Nombre(string) - Client’s full nameTelefono(string) - Client’s phone numberCorreo(string) - Client’s email address
CD_Clientes.InsertarClientes() which executes the stored procedure SP_Clientes_Insert with the following parameters:
@Nombre@Telefono@Correo
Actualizar
Updates an existing client’s information.The client object with updated values:
IdCliente(int) - Client ID to updateNombre(string) - Updated client nameTelefono(string) - Updated phone numberCorreo(string) - Updated email addressEstado(bool) - Client status (active/inactive)
CD_Clientes.ActualizarClientes() which executes the stored procedure SP_Clientes_Update with parameters:
@IdCliente@Nombre@Telefono@Correo@Estado
Eliminar
Deletes a client from the system.The ID of the client to delete
CD_Clientes.EliminarClientes() which executes the stored procedure SP_Clientes_Delete with parameter @id.
Entity Model
TheCE_Clientes entity used by this business logic class:
Business Rules
- Null Safety: The
Listar()method includes null-checking to ensure an empty list is returned instead of null, preventing null reference exceptions in the presentation layer. - Estado Field: The
Estadofield is used to track whether a client is active or inactive, allowing for soft deletes instead of physical removal from the database.
Related Components
- CD_Clientes - Data access layer
- CE_Clientes - Entity model