| | 1 | | using CoWorkingApp.Core.Application.Abstracts; |
| | 2 | |
|
| | 3 | | namespace CoWorkingApp.Core.Domain.Entities |
| | 4 | | { |
| | 5 | | /// <summary> |
| | 6 | | /// Representa una reserva en el sistema. |
| | 7 | | /// </summary> |
| | 8 | | public class Reservation : EntityBase |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Obtiene o establece la fecha de la reserva. |
| | 12 | | /// </summary> |
| 168 | 13 | | public DateTime Date { get; set; } |
| | 14 | |
|
| | 15 | | /// <summary> |
| | 16 | | /// Obtiene o establece el identificador único del usuario asociado a la reserva. |
| | 17 | | /// </summary> |
| 96 | 18 | | public Guid UserId { get; set; } |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Obtiene o establece el usuario asociado a la reserva. |
| | 22 | | /// </summary> |
| 58 | 23 | | public User User { get; set; } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Obtiene o establece el identificador único del asiento asociado a la reserva. |
| | 27 | | /// </summary> |
| 96 | 28 | | public Guid SeatId { get; set; } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Obtiene o establece el asiento asociado a la reserva. |
| | 32 | | /// </summary> |
| 40 | 33 | | public Seat Seat { get; set; } |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// Sobrecarga del método Equals para comparar objetos Reservation por su identificador único. |
| | 37 | | /// </summary> |
| | 38 | | /// <param name="obj">El objeto a comparar con la reserva actual.</param> |
| | 39 | | /// <returns>True si los objetos son iguales, de lo contrario, false.</returns> |
| | 40 | | public override bool Equals(object obj) |
| 6 | 41 | | { |
| | 42 | | // Verifica si el objeto proporcionado no es nulo y es del mismo tipo que Reservation |
| 6 | 43 | | if (obj is null || GetType() != obj.GetType()) |
| 2 | 44 | | { |
| 2 | 45 | | return false; |
| | 46 | | } |
| | 47 | |
|
| | 48 | | // Convierte el objeto a tipo Reservation |
| 4 | 49 | | Reservation other = (Reservation)obj; |
| | 50 | |
|
| | 51 | | // Compara los identificadores únicos para determinar la igualdad |
| 4 | 52 | | return Id.Equals(other.Id); |
| 6 | 53 | | } |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Obtiene un código hash para el objeto actual. |
| | 57 | | /// El código hash se basa en el identificador único (Id) de la reserva. |
| | 58 | | /// </summary> |
| | 59 | | /// <returns>Un código hash para el objeto actual.</returns> |
| | 60 | | public override int GetHashCode() |
| 4 | 61 | | { |
| | 62 | | // Retorna el código hash del identificador único (Id) de la reserva |
| 4 | 63 | | return Id.GetHashCode(); |
| 4 | 64 | | } |
| | 65 | | } |
| | 66 | | } |