Init Commit

This commit is contained in:
2026-01-29 13:43:44 -03:00
commit b9aa8478db
126 changed files with 20649 additions and 0 deletions

View File

@@ -0,0 +1,209 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace MotoresArgentinosV2.Core.Entities;
public class Brand
{
public int BrandID { get; set; }
public int VehicleTypeID { get; set; }
public string Name { get; set; } = string.Empty;
public int? LegacyID { get; set; }
}
public class Model
{
public int ModelID { get; set; }
public int BrandID { get; set; }
public string Name { get; set; } = string.Empty;
public int? LegacyID { get; set; }
}
public enum UserMigrationStatus : byte { LegacyPending = 0, MigratedActive = 1 }
public enum AdStatusEnum
{
Draft = 1,
PaymentPending = 2,
ModerationPending = 3,
Active = 4,
Rejected = 5,
Paused = 6,
Sold = 7,
Expired = 8,
Deleted = 9,
Reserved = 10
}
public class User
{
public int UserID { get; set; }
public string UserName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string PasswordHash { get; set; } = string.Empty;
public string? PasswordSalt { get; set; }
public byte MigrationStatus { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? PhoneNumber { get; set; }
public byte UserType { get; set; } = 1; // 1: Particular, 3: Admin
public string? MFASecret { get; set; }
public bool IsMFAEnabled { get; set; }
// Email Verification
public bool IsEmailVerified { get; set; }
public string? VerificationToken { get; set; }
public DateTime? VerificationTokenExpiresAt { get; set; }
public DateTime? LastVerificationEmailSentAt { get; set; }
// Password Reset
public string? PasswordResetToken { get; set; }
public DateTime? PasswordResetTokenExpiresAt { get; set; }
public DateTime? LastPasswordResetEmailSentAt { get; set; }
// Bloqueo de usuario
public bool IsBlocked { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
// Relación con Refresh Tokens
public ICollection<RefreshToken> RefreshTokens { get; set; } = new List<RefreshToken>();
// Notificaciones de recordatorio de mensajes no leídos
public DateTime? LastUnreadMessageReminderSentAt { get; set; }
}
public class AuditLog
{
public int AuditLogID { get; set; }
public string Action { get; set; } = string.Empty;
public string Entity { get; set; } = string.Empty;
public int EntityID { get; set; }
public int UserID { get; set; }
public string Details { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
public class Ad
{
public int AdID { get; set; }
public int UserID { get; set; }
public User User { get; set; } = null!;
public int VehicleTypeID { get; set; }
public int BrandID { get; set; }
public Brand Brand { get; set; } = null!;
public int ModelID { get; set; }
public Model Model { get; set; } = null!;
public string? VersionName { get; set; }
public int Year { get; set; }
public int KM { get; set; }
public string? FuelType { get; set; }
public string? Color { get; set; }
public string? Segment { get; set; }
public decimal Price { get; set; }
public string Currency { get; set; } = "USD";
public string? Description { get; set; }
public string? Location { get; set; }
public string? Condition { get; set; }
public int? DoorCount { get; set; }
public string? Transmission { get; set; }
public string? Steering { get; set; }
public string? ContactPhone { get; set; }
public string? ContactEmail { get; set; }
public bool DisplayContactInfo { get; set; } = true;
public bool IsFeatured { get; set; }
public int StatusID { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? PublishedAt { get; set; }
public DateTime? ExpiresAt { get; set; }
public int? LegacyAdID { get; set; }
public DateTime? DeletedAt { get; set; }
public int ViewsCounter { get; set; }
public ICollection<AdPhoto> Photos { get; set; } = new List<AdPhoto>();
public ICollection<AdFeature> Features { get; set; } = new List<AdFeature>();
public ICollection<ChatMessage> Messages { get; set; } = new List<ChatMessage>();
// CAMPOS DE CONTROL DE NOTIFICACIONES
public DateTime? LastPerformanceEmailSentAt { get; set; } // Para el resumen semanal
public DateTime? PaymentReminderSentAt { get; set; } // Para carrito abandonado
public bool ExpirationWarningSent { get; set; } // Para aviso por vencer
}
public class AdPhoto
{
public int PhotoID { get; set; }
public int AdID { get; set; }
public string FilePath { get; set; } = string.Empty;
public bool IsCover { get; set; }
public int SortOrder { get; set; }
public Ad Ad { get; set; } = null!;
}
public class AdFeature
{
public int AdID { get; set; }
public string FeatureKey { get; set; } = string.Empty;
public string? FeatureValue { get; set; }
}
public class TransactionRecord
{
public int TransactionID { get; set; }
public int AdID { get; set; }
public Ad Ad { get; set; } = null!;
public string OperationCode { get; set; } = string.Empty;
public int PaymentMethodID { get; set; }
public decimal Amount { get; set; }
public string Status { get; set; } = "PENDING";
public string? ProviderPaymentId { get; set; }
public string? ProviderResponse { get; set; }
public string? SnapshotUserEmail { get; set; }
public string? SnapshotUserName { get; set; }
public string? SnapshotAdTitle { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? UpdatedAt { get; set; }
}
public class Favorite
{
public int UserID { get; set; }
public int AdID { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
public class ChatMessage
{
[Key]
public int MessageID { get; set; }
public int AdID { get; set; }
[ForeignKey("AdID")]
[JsonIgnore]
public Ad? Ad { get; set; }
public int SenderID { get; set; }
public int ReceiverID { get; set; }
public string MessageText { get; set; } = string.Empty;
public DateTime SentAt { get; set; } = DateTime.UtcNow;
public bool IsRead { get; set; } = false;
}
public class PaymentMethod
{
public int PaymentMethodID { get; set; }
public string Name { get; set; } = string.Empty;
}
public class AdViewLog
{
public int Id { get; set; }
public int AdID { get; set; }
public string IPAddress { get; set; } = string.Empty;
public DateTime ViewDate { get; set; } = DateTime.UtcNow;
}

View File

@@ -0,0 +1,18 @@
namespace MotoresArgentinosV2.Core.Entities;
/// <summary>
/// Entidad que representa un medio de pago disponible
/// Tabla legacy: mediodepago (DB: autos)
/// </summary>
public class MedioDePago
{
/// <summary>
/// Identificador único del medio de pago
/// </summary>
public byte Id { get; set; }
/// <summary>
/// Nombre del medio de pago (ej: Visa, MasterCard, etc.)
/// </summary>
public string Mediodepago { get; set; } = string.Empty;
}

View File

@@ -0,0 +1,163 @@
namespace MotoresArgentinosV2.Core.Entities;
/// <summary>
/// Entidad que representa una operación de pago
/// Tabla legacy: operaciones (DB: autos)
/// </summary>
public class Operacion
{
/// <summary>
/// Identificador único de la operación (IDENTITY)
/// </summary>
public int Id { get; set; }
/// <summary>
/// Fecha de la operación
/// </summary>
public DateTime? Fecha { get; set; }
/// <summary>
/// Motivo de la operación
/// </summary>
public string? Motivo { get; set; }
/// <summary>
/// Moneda utilizada
/// </summary>
public string? Moneda { get; set; }
/// <summary>
/// Dirección de entrega
/// </summary>
public string? Direccionentrega { get; set; }
/// <summary>
/// Código de validación de domicilio
/// </summary>
public string? Validaciondomicilio { get; set; }
/// <summary>
/// Código de pedido
/// </summary>
public string? Codigopedido { get; set; }
/// <summary>
/// Nombre para la entrega
/// </summary>
public string? Nombreentrega { get; set; }
/// <summary>
/// Fecha y hora de la transacción
/// </summary>
public string? Fechahora { get; set; }
/// <summary>
/// Teléfono del comprador
/// </summary>
public string? Telefonocomprador { get; set; }
/// <summary>
/// Barrio de entrega
/// </summary>
public string? Barrioentrega { get; set; }
/// <summary>
/// Código de autorización de la transacción
/// </summary>
public string? Codautorizacion { get; set; }
/// <summary>
/// País de entrega
/// </summary>
public string? Paisentrega { get; set; }
/// <summary>
/// Cantidad de cuotas
/// </summary>
public string? Cuotas { get; set; }
/// <summary>
/// Validación de fecha de nacimiento
/// </summary>
public string? Validafechanac { get; set; }
/// <summary>
/// Validación de número de documento
/// </summary>
public string? Validanrodoc { get; set; }
/// <summary>
/// Titular de la tarjeta
/// </summary>
public string? Titular { get; set; }
/// <summary>
/// Número de pedido
/// </summary>
public string? Pedido { get; set; }
/// <summary>
/// Código postal de entrega
/// </summary>
public string? Zipentrega { get; set; }
/// <summary>
/// Monto de la transacción
/// </summary>
public string? Monto { get; set; }
/// <summary>
/// Tipo de tarjeta utilizada
/// </summary>
public string? Tarjeta { get; set; }
/// <summary>
/// Fecha de entrega
/// </summary>
public string? Fechaentrega { get; set; }
/// <summary>
/// Email del comprador
/// </summary>
public string? Emailcomprador { get; set; }
/// <summary>
/// Validación número de puerta
/// </summary>
public string? Validanropuerta { get; set; }
/// <summary>
/// Ciudad de entrega
/// </summary>
public string? Ciudadentrega { get; set; }
/// <summary>
/// Validación tipo de documento
/// </summary>
public string? Validatipodoc { get; set; }
/// <summary>
/// Número de operación
/// </summary>
public string? Noperacion { get; set; }
/// <summary>
/// Estado de la entrega
/// </summary>
public string? Estadoentrega { get; set; }
/// <summary>
/// Resultado de la operación (APROBADA/RECHAZADA)
/// </summary>
public string? Resultado { get; set; }
/// <summary>
/// Mensaje sobre la entrega
/// </summary>
public string? Mensajeentrega { get; set; }
/// <summary>
/// Precio neto de la operación
/// </summary>
public int? Precioneto { get; set; }
}

View File

@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
namespace MotoresArgentinosV2.Core.Entities;
public class RefreshToken
{
[Key]
public int Id { get; set; }
public string Token { get; set; } = string.Empty;
public DateTime Expires { get; set; }
public DateTime Created { get; set; } = DateTime.UtcNow;
public string? CreatedByIp { get; set; }
public DateTime? Revoked { get; set; }
public string? RevokedByIp { get; set; }
public string? ReplacedByToken { get; set; }
public bool IsActive => Revoked == null && !IsExpired;
public bool IsExpired => DateTime.UtcNow >= Expires;
public int UserId { get; set; }
public User User { get; set; } = null!;
}