using Microsoft.EntityFrameworkCore; namespace RR3CommunityServer.Data; public class RR3DbContext : DbContext { public RR3DbContext(DbContextOptions options) : base(options) { } public DbSet Devices { get; set; } public DbSet Users { get; set; } public DbSet Sessions { get; set; } public DbSet Purchases { get; set; } public DbSet CatalogItems { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); // Seed some default catalog items modelBuilder.Entity().HasData( new CatalogItem { Id = 1, Sku = "com.ea.rr3.gold_1000", Name = "1000 Gold", Type = "currency", Price = 0.99m, Available = true }, new CatalogItem { Id = 2, Sku = "com.ea.rr3.car_tier1", Name = "Starter Car", Type = "car", Price = 0m, Available = true }, new CatalogItem { Id = 3, Sku = "com.ea.rr3.upgrade_engine", Name = "Engine Upgrade", Type = "upgrade", Price = 4.99m, Available = true } ); } } // Database entities public class Device { public int Id { get; set; } public string DeviceId { get; set; } = string.Empty; public string HardwareId { get; set; } = string.Empty; public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public DateTime LastSeenAt { get; set; } = DateTime.UtcNow; } public class User { public int Id { get; set; } public string SynergyId { get; set; } = string.Empty; public string? DeviceId { get; set; } public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public string? Nickname { get; set; } } public class Session { public int Id { get; set; } public string SessionId { get; set; } = string.Empty; public string? SynergyId { get; set; } public string DeviceId { get; set; } = string.Empty; public int? UserId { get; set; } public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public DateTime ExpiresAt { get; set; } } public class Purchase { public int Id { get; set; } public string SynergyId { get; set; } = string.Empty; public string ItemId { get; set; } = string.Empty; public string Sku { get; set; } = string.Empty; public string OrderId { get; set; } = string.Empty; public DateTime PurchaseTime { get; set; } = DateTime.UtcNow; public string Token { get; set; } = string.Empty; public decimal Price { get; set; } public string Status { get; set; } = "approved"; // For web panel display public int? UserId { get; set; } public DateTime PurchaseDate => PurchaseTime; } public class CatalogItem { public int Id { get; set; } public string Sku { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; public string Type { get; set; } = string.Empty; public decimal Price { get; set; } public bool Available { get; set; } = true; }