Overview
TheCN_Reservas class provides business logic operations for managing sports court reservations. It handles reservation CRUD operations and includes advanced features like filtering reservations by client name.
Namespace: capa_negocio
Dependencies:
capa_entidad.CE_Reservas- Reservation entity modelcapa_entidad.ReservaViewModel- View model for creating reservationscapa_dato.CD_Reservas- Data access layer for reservations
Class Definition
Methods
Listar
Retrieves a list of all reservations from the database.A list of all reservations in the system, including client and court information
CD_Reservas.Listar() which executes the stored procedure SP_Reservas_List.
InsertarReservas
Creates a new reservation in the system using a view model that includes reservation data along with related lists.The reservation view model containing:
Reserva(CE_Reservas) - The reservation object with:IdCancha(int) - Court IDIdCliente(int) - Client IDIdUsuario(int) - User ID who creates the reservationFechaReserva(DateTime) - Reservation dateHoraInicio(TimeSpan) - Start timeHoraFin(TimeSpan) - End timeComentario(string) - Optional comments
ListaClientes(List of CE_Clientes) - Available clientsListaCanchas(List of CE_Canchas) - Available courts
CD_Reservas.InsertarReserva() which executes the stored procedure SP_Reservas_Insert with the following parameters:
@IdCancha@IdCliente@IdUsuario@FechaReserva@HoraInicio@HoraFin@Comentario
Actualizar
Updates an existing reservation’s information.The reservation object with updated values:
IdReserva(int) - Reservation ID to updateIdCancha(int) - Updated court IDIdCliente(int) - Updated client IDIdUsuario(int) - Updated user IDFechaReserva(DateTime) - Updated reservation dateHoraInicio(TimeSpan) - Updated start timeHoraFin(TimeSpan) - Updated end timeNombreCliente(string) - Client nameComentario(string) - Updated commentsEstado(bool) - Reservation status
CD_Reservas.ActualizarReserva() which executes the stored procedure SP_Reservas_Update with all reservation parameters.
Eliminar
Deletes a reservation from the system.The ID of the reservation to delete
CD_Reservas.EliminarReserva() which executes the stored procedure SP_Reservas_Delete with parameter @Id.
ListarNombre
Filters and retrieves reservations by client name. This method enables searching for specific reservations.The client name or partial name to search for
A list of reservations matching the search criteria
CD_Reservas.ListarNombre() which executes the stored procedure SP_Listar_Reservas_Nombre with parameter @Buscar.
Entity Models
CE_Reservas
The main reservation entity:ReservaViewModel
View model used for creating reservations:Business Features
- Search Functionality: The
ListarNombre()method enables filtering reservations by client name for quick lookups. - View Model Pattern: Uses
ReservaViewModelfor insertions to provide additional context (available clients and courts) to the presentation layer. - Time Management: Handles both date (
DateTime) and time (TimeSpan) types for precise reservation scheduling.
Related Components
- CD_Reservas - Data access layer
- CE_Reservas - Entity model
- CN_Clientes - Client business logic
- CN_Canchas - Court business logic