Overview
TheCN_Usuarios class handles the business logic for user management operations. It validates user data, enforces password policies, and coordinates with the data layer for database operations.
Methods
Listar()
Retrieves all users from the database. Returns:List<CE_usuarios> - List of all system users
Example:
- Calls
CD_Usuarios.ListarUsuarios() - Executes stored procedure
SP_Usuarios_List
Insertar(CE_usuarios)
Adds a new user to the system with validation.The user object to insert with the following validated properties:
Nombre(string) - Required, cannot be emptyClave(string) - Required, minimum 6 charactersEstado(bool) - User active status
- Username (
Nombre) cannot be empty or whitespace - Password (
Clave) is mandatory and must be at least 6 characters - Throws
ArgumentExceptionif validation fails
capa_negocio/CN_Usuarios.cs:29-61
Data Layer Call:
- Calls
CD_Usuarios.InsertarUsuarios() - Executes stored procedure
SP_Usuarios_Insert
Actualizar(CE_usuarios)
Updates an existing user’s information.The user object with updated information:
IdUsuario(int) - Required, must be greater than 0Nombre(string) - Required, cannot be emptyClave(string) - Optional for updatesEstado(bool) - User active status
- User ID must be valid (greater than 0)
- Username cannot be empty
- Throws
ArgumentExceptionif validation fails
capa_negocio/CN_Usuarios.cs:64-87
Data Layer Call:
- Calls
CD_Usuarios.ActualizarUsuarios() - Executes stored procedure
SP_Usuarios_Update
Eliminar(int)
Removes a user from the system.The ID of the user to delete. Must be greater than 0.
- User ID must be valid (greater than 0)
- Throws
ArgumentExceptionif validation fails
capa_negocio/CN_Usuarios.cs:90-106
Data Layer Call:
- Calls
CD_Usuarios.EliminarUsuarios() - Executes stored procedure
SP_Usuarios_Delete
Consider implementing soft deletes (setting Estado to false) instead of hard deletes to maintain data integrity and audit trails.
Password Validation Rules
The business layer enforces the following password policy:Entity Model
Related Components
CE_Usuarios Entity
View the user entity structure
User Management Feature
Learn about the user management feature