Add Bazaar store products — booster packs, prebuilt decks, masked listings
- BoosterPack entity: dual pricing (OP + USD), JSONB slot distribution, availability window, CDN image, IsActive flag - PrebuiltDeck entity: dual pricing, ArchSpirit reference (denormalized), availability window, CDN image, card list (PrebuiltDeckCard) - BazaarListing.IsMasked: blind/mystery market — buyers see rarity+type only - BazaarDbContext: new DbSets, EF config (jsonb column, unique indexes, cascade delete on deck cards) - Migration: AddBazaarStoreProducts (applied to pg-forge-01) - Admin UI: BoosterPackList, BoosterPackEditor (slot editor, image upload), PrebuiltDeckList, PrebuiltDeckEditor (cross-context card search, ArchSpirit picker) - BazaarOverview: add active packs/decks stat cards with manage links - NavMenu: add Booster Packs + Prebuilt Decks sub-items under Bazaar Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -20,9 +20,21 @@
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link text-white" href="/bazaar">
|
||||
<NavLink class="nav-link text-white" href="/bazaar" Match="NavLinkMatch.All">
|
||||
<i class="bi bi-shop me-2"></i>Bazaar
|
||||
</NavLink>
|
||||
<ul class="nav nav-pills flex-column gap-1 ps-3 mt-1">
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link text-white-50 py-1" href="/bazaar/packs">
|
||||
<i class="bi bi-box-seam me-2"></i>Booster Packs
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link text-white-50 py-1" href="/bazaar/decks">
|
||||
<i class="bi bi-stack me-2"></i>Prebuilt Decks
|
||||
</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link text-white" href="/feature-flags">
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
<h1 class="mb-4">Bazaar</h1>
|
||||
|
||||
<div class="row g-4 mb-4">
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small mb-1">Active Listings</div>
|
||||
<div class="text-muted small mb-1">Active P2P Listings</div>
|
||||
<div class="fs-3 fw-bold text-success">@(_active ?? 0)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small mb-1">Total Transactions</div>
|
||||
@@ -23,6 +23,24 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small mb-1">Active Booster Packs</div>
|
||||
<div class="fs-3 fw-bold text-primary">@(_activePacks ?? 0)</div>
|
||||
<a href="/bazaar/packs" class="small text-decoration-none">Manage →</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small mb-1">Active Prebuilt Decks</div>
|
||||
<div class="fs-3 fw-bold text-info">@(_activeDecks ?? 0)</div>
|
||||
<a href="/bazaar/decks" class="small text-decoration-none">Manage →</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
@@ -66,13 +84,17 @@
|
||||
@code {
|
||||
private int? _active;
|
||||
private int? _txCount;
|
||||
private int? _activePacks;
|
||||
private int? _activeDecks;
|
||||
private List<BazaarTransaction>? _recentTx;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_active = await Db.Listings.CountAsync(l => l.Status == BazaarListingStatus.Active);
|
||||
_txCount = await Db.Transactions.CountAsync();
|
||||
_recentTx = await Db.Transactions
|
||||
_active = await Db.Listings.CountAsync(l => l.Status == BazaarListingStatus.Active);
|
||||
_txCount = await Db.Transactions.CountAsync();
|
||||
_activePacks = await Db.BoosterPacks.CountAsync(p => p.IsActive);
|
||||
_activeDecks = await Db.PrebuiltDecks.CountAsync(d => d.IsActive);
|
||||
_recentTx = await Db.Transactions
|
||||
.OrderByDescending(t => t.TransactedAt)
|
||||
.Take(50)
|
||||
.ToListAsync();
|
||||
|
||||
@@ -0,0 +1,309 @@
|
||||
@page "/bazaar/packs/new"
|
||||
@page "/bazaar/packs/{Id:guid}"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@inject BazaarDbContext Db
|
||||
@inject SOR.Cdn.ICdnClient Cdn
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<PageTitle>@(_isNew ? "New Pack" : _pack?.Name ?? "Pack") – SOR Admin</PageTitle>
|
||||
|
||||
@if (_pack == null)
|
||||
{
|
||||
<p class="text-muted">Loading…</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<a href="/bazaar/packs" class="text-muted text-decoration-none small">
|
||||
<i class="bi bi-arrow-left me-1"></i>Booster Packs
|
||||
</a>
|
||||
<h1 class="mb-0 mt-1">@(_isNew ? "New Booster Pack" : _pack.Name)</h1>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
@if (!_isNew)
|
||||
{
|
||||
<button class="btn btn-outline-danger btn-sm" @onclick="DeleteAsync">
|
||||
<i class="bi bi-trash"></i> Delete
|
||||
</button>
|
||||
}
|
||||
<button class="btn btn-primary" @onclick="SaveAsync" disabled="@_saving">
|
||||
@if (_saving) { <span class="spinner-border spinner-border-sm me-1"></span> }
|
||||
<i class="bi bi-floppy me-1"></i>Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (_error != null) { <div class="alert alert-danger">@_error</div> }
|
||||
@if (_success) { <div class="alert alert-success">Saved successfully.</div> }
|
||||
|
||||
<div class="row g-4">
|
||||
<!-- Left column: identity + pricing -->
|
||||
<div class="col-lg-7">
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header fw-medium">Details</div>
|
||||
<div class="card-body row g-3">
|
||||
<div class="col-12">
|
||||
<label class="form-label">Name <span class="text-danger">*</span></label>
|
||||
<input @bind="_pack.Name" class="form-control" placeholder="e.g. Core Set Booster" />
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label">Description</label>
|
||||
<textarea @bind="_pack.Description" class="form-control" rows="3"
|
||||
placeholder="What's in this pack?"></textarea>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Origin Points Price</label>
|
||||
<div class="input-group">
|
||||
<input @bind="_pack.OriginPointPrice" type="number" min="0" class="form-control" />
|
||||
<span class="input-group-text">OP</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">USD Price <span class="text-muted small">(optional)</span></label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">$</span>
|
||||
<input @bind="_usdInput" type="number" min="0" step="0.01"
|
||||
class="form-control" placeholder="—" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 d-flex align-items-end">
|
||||
<div class="form-check">
|
||||
<input @bind="_pack.IsActive" type="checkbox" class="form-check-input" id="chkActive" />
|
||||
<label class="form-check-label fw-medium" for="chkActive">Active</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Availability window -->
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header fw-medium">Availability Window</div>
|
||||
<div class="card-body row g-3">
|
||||
<div class="form-text col-12 pt-0 mt-0">
|
||||
Leave blank for no restriction. Pack must also be Active to appear in-game.
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Available From</label>
|
||||
<input value="@_availableFrom" @onchange="e => _availableFrom = e.Value?.ToString()"
|
||||
type="datetime-local" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Available Until</label>
|
||||
<input value="@_availableUntil" @onchange="e => _availableUntil = e.Value?.ToString()"
|
||||
type="datetime-local" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Slot distribution -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium d-flex justify-content-between align-items-center">
|
||||
<span>Card Slots</span>
|
||||
<button class="btn btn-sm btn-outline-secondary" @onclick="AddSlot">
|
||||
<i class="bi bi-plus-lg me-1"></i>Add Slot
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-text mb-3">
|
||||
Defines how many cards of each rarity drop per pack. When a player opens a pack,
|
||||
the server draws randomly from cards matching each slot's rarity.
|
||||
</div>
|
||||
@if (_slots.Count == 0)
|
||||
{
|
||||
<p class="text-muted small">No slots defined yet.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr><th>Rarity</th><th style="width:100px">Count</th><th style="width:50px"></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var slot in _slots)
|
||||
{
|
||||
var s = slot;
|
||||
<tr>
|
||||
<td>
|
||||
<select @bind="s.Rarity" class="form-select form-select-sm">
|
||||
@foreach (var r in Enum.GetValues<CardRarity>())
|
||||
{
|
||||
<option value="@r">@r</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input @bind="s.Count" type="number" min="1"
|
||||
class="form-control form-control-sm" />
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-danger"
|
||||
@onclick="() => _slots.Remove(s)">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="text-muted small">
|
||||
Total cards per pack: <strong>@_slots.Sum(s => s.Count)</strong>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right column: pack image -->
|
||||
<div class="col-lg-5">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium">Pack Image</div>
|
||||
<div class="card-body text-center">
|
||||
@if (!string.IsNullOrEmpty(_pack.ImageCdnUrl))
|
||||
{
|
||||
<img src="@_pack.ImageCdnUrl" alt="Pack image"
|
||||
class="img-fluid rounded mb-3" style="max-height:280px" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="border rounded d-flex align-items-center justify-content-center mb-3"
|
||||
style="height:180px;background:#f8f9fa">
|
||||
<span class="text-muted"><i class="bi bi-image fs-1"></i></span>
|
||||
</div>
|
||||
}
|
||||
|
||||
<label class="btn btn-outline-primary @(_uploadingImage ? "disabled" : "")">
|
||||
@if (_uploadingImage)
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm me-1"></span><text>Uploading...</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="bi bi-upload me-1"></i><text>Upload Image</text>
|
||||
}
|
||||
<InputFile style="display:none" accept="image/*" OnChange="UploadImageAsync" />
|
||||
</label>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_pack.ImageCdnUrl))
|
||||
{
|
||||
<div class="mt-2">
|
||||
<input @bind="_pack.ImageCdnUrl" class="form-control form-control-sm"
|
||||
placeholder="CDN URL" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public Guid? Id { get; set; }
|
||||
|
||||
private BoosterPack? _pack;
|
||||
private bool _isNew;
|
||||
private bool _saving;
|
||||
private bool _uploadingImage;
|
||||
private string? _error;
|
||||
private bool _success;
|
||||
private string? _usdInput;
|
||||
private string? _availableFrom;
|
||||
private string? _availableUntil;
|
||||
private readonly List<PackSlot> _slots = new();
|
||||
|
||||
private sealed class PackSlot
|
||||
{
|
||||
public CardRarity Rarity { get; set; } = CardRarity.Common;
|
||||
public int Count { get; set; } = 1;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_isNew = Id == null;
|
||||
if (_isNew)
|
||||
{
|
||||
_pack = new BoosterPack { CreatedAt = DateTimeOffset.UtcNow, UpdatedAt = DateTimeOffset.UtcNow };
|
||||
}
|
||||
else
|
||||
{
|
||||
_pack = await Db.BoosterPacks.FirstOrDefaultAsync(p => p.Id == Id);
|
||||
if (_pack != null)
|
||||
{
|
||||
_usdInput = _pack.UsdPrice?.ToString("F2");
|
||||
_availableFrom = _pack.AvailableFrom?.LocalDateTime.ToString("yyyy-MM-ddTHH:mm");
|
||||
_availableUntil = _pack.AvailableUntil?.LocalDateTime.ToString("yyyy-MM-ddTHH:mm");
|
||||
ParseSlots(_pack.SlotsJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ParseSlots(string? json)
|
||||
{
|
||||
_slots.Clear();
|
||||
if (string.IsNullOrWhiteSpace(json)) return;
|
||||
try
|
||||
{
|
||||
var raw = System.Text.Json.JsonSerializer.Deserialize<List<SlotDto>>(json);
|
||||
if (raw != null)
|
||||
_slots.AddRange(raw.Select(s =>
|
||||
new PackSlot { Rarity = s.Rarity, Count = s.Count }));
|
||||
}
|
||||
catch { /* malformed JSON — start fresh */ }
|
||||
}
|
||||
|
||||
private record SlotDto(CardRarity Rarity, int Count);
|
||||
|
||||
private void AddSlot() => _slots.Add(new PackSlot());
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (_pack == null) return;
|
||||
_saving = true; _error = null; _success = false;
|
||||
try
|
||||
{
|
||||
_pack.UsdPrice = decimal.TryParse(_usdInput, out var usd) ? usd : null;
|
||||
_pack.AvailableFrom = DateTime.TryParse(_availableFrom, out var af)
|
||||
? new DateTimeOffset(af, TimeZoneInfo.Local.GetUtcOffset(af)) : null;
|
||||
_pack.AvailableUntil = DateTime.TryParse(_availableUntil, out var au)
|
||||
? new DateTimeOffset(au, TimeZoneInfo.Local.GetUtcOffset(au)) : null;
|
||||
_pack.SlotsJson = _slots.Count > 0
|
||||
? System.Text.Json.JsonSerializer.Serialize(
|
||||
_slots.Select(s => new SlotDto(s.Rarity, s.Count)))
|
||||
: null;
|
||||
_pack.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
if (_isNew) Db.BoosterPacks.Add(_pack);
|
||||
await Db.SaveChangesAsync();
|
||||
_success = true;
|
||||
if (_isNew) { _isNew = false; Nav.NavigateTo($"/bazaar/packs/{_pack.Id}", replace: true); }
|
||||
}
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
finally { _saving = false; }
|
||||
}
|
||||
|
||||
private async Task DeleteAsync()
|
||||
{
|
||||
if (_pack == null || _isNew) return;
|
||||
Db.BoosterPacks.Remove(_pack);
|
||||
await Db.SaveChangesAsync();
|
||||
Nav.NavigateTo("/bazaar/packs");
|
||||
}
|
||||
|
||||
private async Task UploadImageAsync(InputFileChangeEventArgs e)
|
||||
{
|
||||
if (_pack == null) return;
|
||||
_uploadingImage = true; _error = null;
|
||||
try
|
||||
{
|
||||
var file = e.File;
|
||||
var folder = $"bazaar/packs/{_pack.Id}";
|
||||
await using var stream = file.OpenReadStream(maxAllowedSize: 10 * 1024 * 1024);
|
||||
var result = await Cdn.UploadAsync(folder, file.Name, file.ContentType, stream);
|
||||
if (result.Success)
|
||||
_pack.ImageCdnUrl = result.PublicUrl;
|
||||
else
|
||||
_error = $"Upload failed: {result.Error}";
|
||||
}
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
finally { _uploadingImage = false; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
@page "/bazaar/packs"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@inject BazaarDbContext Db
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<PageTitle>Booster Packs – SOR Admin</PageTitle>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="mb-0">Booster Packs</h1>
|
||||
<a href="/bazaar/packs/new" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i>New Pack
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if (_packs == null)
|
||||
{
|
||||
<p class="text-muted">Loading…</p>
|
||||
}
|
||||
else if (_packs.Count == 0)
|
||||
{
|
||||
<div class="alert alert-info">No booster packs yet. Create one to get started.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Origin Points</th>
|
||||
<th>USD</th>
|
||||
<th>Available</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var pack in _packs)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
@if (!string.IsNullOrEmpty(pack.ImageCdnUrl))
|
||||
{
|
||||
<img src="@pack.ImageCdnUrl" alt="" style="width:40px;height:40px;object-fit:cover;border-radius:4px" />
|
||||
}
|
||||
<span class="fw-medium">@pack.Name</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>@pack.OriginPointPrice.ToString("N0") OP</td>
|
||||
<td>@(pack.UsdPrice.HasValue ? $"${pack.UsdPrice:F2}" : "—")</td>
|
||||
<td class="small text-muted">@FormatWindow(pack.AvailableFrom, pack.AvailableUntil)</td>
|
||||
<td>
|
||||
@if (pack.IsActive && IsCurrentlyAvailable(pack))
|
||||
{
|
||||
<span class="badge bg-success">Live</span>
|
||||
}
|
||||
else if (pack.IsActive)
|
||||
{
|
||||
<span class="badge bg-warning text-dark">Active / Not in Window</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-secondary">Inactive</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<a href="/bazaar/packs/@pack.Id" class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-pencil"></i> Edit
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
private List<BoosterPack>? _packs;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
=> _packs = await Db.BoosterPacks.OrderByDescending(p => p.CreatedAt).ToListAsync();
|
||||
|
||||
private static string FormatWindow(DateTimeOffset? from, DateTimeOffset? until) =>
|
||||
(from, until) switch
|
||||
{
|
||||
(null, null) => "Always",
|
||||
({ } f, null) => $"From {f:yyyy-MM-dd}",
|
||||
(null, { } u) => $"Until {u:yyyy-MM-dd}",
|
||||
({ } f, { } u) => $"{f:yyyy-MM-dd} → {u:yyyy-MM-dd}",
|
||||
};
|
||||
|
||||
private static bool IsCurrentlyAvailable(BoosterPack p)
|
||||
{
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
return (p.AvailableFrom == null || p.AvailableFrom <= now)
|
||||
&& (p.AvailableUntil == null || p.AvailableUntil >= now);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
@page "/bazaar/decks/new"
|
||||
@page "/bazaar/decks/{Id:guid}"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@inject BazaarDbContext Db
|
||||
@inject CatalogDbContext CatalogDb
|
||||
@inject SOR.Cdn.ICdnClient Cdn
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<PageTitle>@(_isNew ? "New Deck" : _deck?.Name ?? "Deck") – SOR Admin</PageTitle>
|
||||
|
||||
@if (_deck == null)
|
||||
{
|
||||
<p class="text-muted">Loading…</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<a href="/bazaar/decks" class="text-muted text-decoration-none small">
|
||||
<i class="bi bi-arrow-left me-1"></i>Prebuilt Decks
|
||||
</a>
|
||||
<h1 class="mb-0 mt-1">@(_isNew ? "New Prebuilt Deck" : _deck.Name)</h1>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
@if (!_isNew)
|
||||
{
|
||||
<button class="btn btn-outline-danger btn-sm" @onclick="DeleteAsync">
|
||||
<i class="bi bi-trash"></i> Delete
|
||||
</button>
|
||||
}
|
||||
<button class="btn btn-primary" @onclick="SaveAsync" disabled="@_saving">
|
||||
@if (_saving) { <span class="spinner-border spinner-border-sm me-1"></span> }
|
||||
<i class="bi bi-floppy me-1"></i>Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (_error != null) { <div class="alert alert-danger">@_error</div> }
|
||||
@if (_success) { <div class="alert alert-success">Saved successfully.</div> }
|
||||
|
||||
<div class="row g-4">
|
||||
<!-- Left: details + card list -->
|
||||
<div class="col-lg-7">
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header fw-medium">Details</div>
|
||||
<div class="card-body row g-3">
|
||||
<div class="col-12">
|
||||
<label class="form-label">Name <span class="text-danger">*</span></label>
|
||||
<input @bind="_deck.Name" class="form-control" placeholder="e.g. Void Starter Deck" />
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label">Description</label>
|
||||
<textarea @bind="_deck.Description" class="form-control" rows="2"></textarea>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Origin Points Price</label>
|
||||
<div class="input-group">
|
||||
<input @bind="_deck.OriginPointPrice" type="number" min="0" class="form-control" />
|
||||
<span class="input-group-text">OP</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">USD Price <span class="text-muted small">(optional)</span></label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">$</span>
|
||||
<input @bind="_usdInput" type="number" min="0" step="0.01"
|
||||
class="form-control" placeholder="—" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 d-flex align-items-end">
|
||||
<div class="form-check">
|
||||
<input @bind="_deck.IsActive" type="checkbox" class="form-check-input" id="chkActive" />
|
||||
<label class="form-check-label fw-medium" for="chkActive">Active</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Availability -->
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header fw-medium">Availability Window</div>
|
||||
<div class="card-body row g-3">
|
||||
<div class="form-text col-12 pt-0 mt-0">Leave blank for no restriction.</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Available From</label>
|
||||
<input value="@_availableFrom" @onchange="e => _availableFrom = e.Value?.ToString()"
|
||||
type="datetime-local" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Available Until</label>
|
||||
<input value="@_availableUntil" @onchange="e => _availableUntil = e.Value?.ToString()"
|
||||
type="datetime-local" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ArchSpirit -->
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header fw-medium">ArchSpirit</div>
|
||||
<div class="card-body">
|
||||
@if (_deck.ArchSpiritCardDefinitionId.HasValue)
|
||||
{
|
||||
<div class="d-flex align-items-center gap-2 mb-2">
|
||||
<span class="badge bg-primary">@_deck.ArchSpiritName</span>
|
||||
<button class="btn btn-sm btn-outline-danger"
|
||||
@onclick="() => { _deck.ArchSpiritCardDefinitionId = null; _deck.ArchSpiritName = null; }">
|
||||
<i class="bi bi-x"></i> Remove
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
<div class="input-group">
|
||||
<input @bind="_archSearch" class="form-control form-control-sm"
|
||||
placeholder="Search ArchSpirit by name…" />
|
||||
<button class="btn btn-outline-secondary btn-sm" @onclick="SearchArchSpiritsAsync">
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
@if (_archResults.Count > 0)
|
||||
{
|
||||
<div class="list-group mt-2">
|
||||
@foreach (var card in _archResults)
|
||||
{
|
||||
var c = card;
|
||||
<button class="list-group-item list-group-item-action py-1"
|
||||
@onclick="() => SelectArchSpirit(c)">
|
||||
<span class="fw-medium">@c.Name</span>
|
||||
<span class="text-muted small ms-2">@c.Affinity</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Card list -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium d-flex justify-content-between align-items-center">
|
||||
<span>Cards <span class="badge bg-secondary ms-1">@_deck.Cards.Count</span></span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<!-- Search + add -->
|
||||
<div class="input-group mb-3">
|
||||
<input @bind="_cardSearch" class="form-control form-control-sm"
|
||||
placeholder="Search card by name to add…" />
|
||||
<button class="btn btn-outline-secondary btn-sm" @onclick="SearchCardsAsync">
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
@if (_cardResults.Count > 0)
|
||||
{
|
||||
<div class="list-group mb-3">
|
||||
@foreach (var card in _cardResults)
|
||||
{
|
||||
var c = card;
|
||||
<button class="list-group-item list-group-item-action py-1"
|
||||
@onclick="() => AddCard(c)">
|
||||
<span class="fw-medium">@c.Name</span>
|
||||
<span class="badge bg-secondary ms-2 small">@c.CardType</span>
|
||||
<span class="text-muted small ms-1">@c.Affinity</span>
|
||||
<i class="bi bi-plus-circle float-end text-primary mt-1"></i>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Existing deck cards -->
|
||||
@if (_deck.Cards.Count > 0)
|
||||
{
|
||||
<table class="table table-sm">
|
||||
<thead><tr><th>Card</th><th style="width:100px">Qty</th><th style="width:50px"></th></tr></thead>
|
||||
<tbody>
|
||||
@foreach (var entry in _deck.Cards.OrderBy(c => c.CardName))
|
||||
{
|
||||
var e = entry;
|
||||
<tr>
|
||||
<td>@e.CardName</td>
|
||||
<td>
|
||||
<input @bind="e.Quantity" type="number" min="1" max="4"
|
||||
class="form-control form-control-sm" />
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-danger"
|
||||
@onclick="() => RemoveCard(e)">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="text-muted small">
|
||||
Total cards: <strong>@_deck.Cards.Sum(c => c.Quantity)</strong>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right: deck image -->
|
||||
<div class="col-lg-5">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium">Deck Image</div>
|
||||
<div class="card-body text-center">
|
||||
@if (!string.IsNullOrEmpty(_deck.ImageCdnUrl))
|
||||
{
|
||||
<img src="@_deck.ImageCdnUrl" alt="Deck image"
|
||||
class="img-fluid rounded mb-3" style="max-height:280px" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="border rounded d-flex align-items-center justify-content-center mb-3"
|
||||
style="height:180px;background:#f8f9fa">
|
||||
<span class="text-muted"><i class="bi bi-stack fs-1"></i></span>
|
||||
</div>
|
||||
}
|
||||
|
||||
<label class="btn btn-outline-primary @(_uploadingImage ? "disabled" : "")">
|
||||
@if (_uploadingImage)
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm me-1"></span><text>Uploading...</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="bi bi-upload me-1"></i><text>Upload Image</text>
|
||||
}
|
||||
<InputFile style="display:none" accept="image/*" OnChange="UploadImageAsync" />
|
||||
</label>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_deck.ImageCdnUrl))
|
||||
{
|
||||
<div class="mt-2">
|
||||
<input @bind="_deck.ImageCdnUrl" class="form-control form-control-sm"
|
||||
placeholder="CDN URL" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public Guid? Id { get; set; }
|
||||
|
||||
private PrebuiltDeck? _deck;
|
||||
private bool _isNew;
|
||||
private bool _saving;
|
||||
private bool _uploadingImage;
|
||||
private string? _error;
|
||||
private bool _success;
|
||||
private string? _usdInput;
|
||||
private string? _availableFrom;
|
||||
private string? _availableUntil;
|
||||
|
||||
// Card search
|
||||
private string _cardSearch = string.Empty;
|
||||
private List<CardDefinition> _cardResults = new();
|
||||
private string _archSearch = string.Empty;
|
||||
private List<CardDefinition> _archResults = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_isNew = Id == null;
|
||||
if (_isNew)
|
||||
{
|
||||
_deck = new PrebuiltDeck { CreatedAt = DateTimeOffset.UtcNow, UpdatedAt = DateTimeOffset.UtcNow };
|
||||
}
|
||||
else
|
||||
{
|
||||
_deck = await Db.PrebuiltDecks
|
||||
.Include(d => d.Cards)
|
||||
.FirstOrDefaultAsync(d => d.Id == Id);
|
||||
if (_deck != null)
|
||||
{
|
||||
_usdInput = _deck.UsdPrice?.ToString("F2");
|
||||
_availableFrom = _deck.AvailableFrom?.LocalDateTime.ToString("yyyy-MM-ddTHH:mm");
|
||||
_availableUntil = _deck.AvailableUntil?.LocalDateTime.ToString("yyyy-MM-ddTHH:mm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SearchCardsAsync()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_cardSearch)) return;
|
||||
_cardResults = await CatalogDb.CardDefinitions
|
||||
.Where(c => c.Name.Contains(_cardSearch))
|
||||
.OrderBy(c => c.Name)
|
||||
.Take(10)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
private async Task SearchArchSpiritsAsync()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_archSearch)) return;
|
||||
_archResults = await CatalogDb.CardDefinitions
|
||||
.Where(c => c.CardType == CardType.ArchSpirit && c.Name.Contains(_archSearch))
|
||||
.OrderBy(c => c.Name)
|
||||
.Take(10)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
private void AddCard(CardDefinition card)
|
||||
{
|
||||
if (_deck!.Cards.Any(c => c.CardDefinitionId == card.Id)) return;
|
||||
_deck.Cards.Add(new PrebuiltDeckCard
|
||||
{
|
||||
CardDefinitionId = card.Id,
|
||||
CardName = card.Name,
|
||||
Quantity = 1,
|
||||
PrebuiltDeckId = _deck.Id,
|
||||
});
|
||||
_cardSearch = string.Empty;
|
||||
_cardResults.Clear();
|
||||
}
|
||||
|
||||
private void SelectArchSpirit(CardDefinition card)
|
||||
{
|
||||
_deck!.ArchSpiritCardDefinitionId = card.Id;
|
||||
_deck.ArchSpiritName = card.Name;
|
||||
_archSearch = string.Empty;
|
||||
_archResults.Clear();
|
||||
}
|
||||
|
||||
private void RemoveCard(PrebuiltDeckCard entry)
|
||||
{
|
||||
_deck!.Cards.Remove(entry);
|
||||
if (entry.Id != Guid.Empty)
|
||||
Db.PrebuiltDeckCards.Remove(entry);
|
||||
}
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (_deck == null) return;
|
||||
_saving = true; _error = null; _success = false;
|
||||
try
|
||||
{
|
||||
_deck.UsdPrice = decimal.TryParse(_usdInput, out var usd) ? usd : null;
|
||||
_deck.AvailableFrom = DateTime.TryParse(_availableFrom, out var af)
|
||||
? new DateTimeOffset(af, TimeZoneInfo.Local.GetUtcOffset(af)) : null;
|
||||
_deck.AvailableUntil = DateTime.TryParse(_availableUntil, out var au)
|
||||
? new DateTimeOffset(au, TimeZoneInfo.Local.GetUtcOffset(au)) : null;
|
||||
_deck.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
if (_isNew) Db.PrebuiltDecks.Add(_deck);
|
||||
await Db.SaveChangesAsync();
|
||||
_success = true;
|
||||
if (_isNew) { _isNew = false; Nav.NavigateTo($"/bazaar/decks/{_deck.Id}", replace: true); }
|
||||
}
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
finally { _saving = false; }
|
||||
}
|
||||
|
||||
private async Task DeleteAsync()
|
||||
{
|
||||
if (_deck == null || _isNew) return;
|
||||
Db.PrebuiltDecks.Remove(_deck);
|
||||
await Db.SaveChangesAsync();
|
||||
Nav.NavigateTo("/bazaar/decks");
|
||||
}
|
||||
|
||||
private async Task UploadImageAsync(InputFileChangeEventArgs e)
|
||||
{
|
||||
if (_deck == null) return;
|
||||
_uploadingImage = true; _error = null;
|
||||
try
|
||||
{
|
||||
var file = e.File;
|
||||
var folder = $"bazaar/decks/{_deck.Id}";
|
||||
await using var stream = file.OpenReadStream(maxAllowedSize: 10 * 1024 * 1024);
|
||||
var result = await Cdn.UploadAsync(folder, file.Name, file.ContentType, stream);
|
||||
if (result.Success)
|
||||
_deck.ImageCdnUrl = result.PublicUrl;
|
||||
else
|
||||
_error = $"Upload failed: {result.Error}";
|
||||
}
|
||||
catch (Exception ex) { _error = ex.Message; }
|
||||
finally { _uploadingImage = false; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
@page "/bazaar/decks"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@inject BazaarDbContext Db
|
||||
|
||||
<PageTitle>Prebuilt Decks – SOR Admin</PageTitle>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="mb-0">Prebuilt Decks</h1>
|
||||
<a href="/bazaar/decks/new" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i>New Deck
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if (_decks == null)
|
||||
{
|
||||
<p class="text-muted">Loading…</p>
|
||||
}
|
||||
else if (_decks.Count == 0)
|
||||
{
|
||||
<div class="alert alert-info">No prebuilt decks yet. Create one to get started.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>ArchSpirit</th>
|
||||
<th>Cards</th>
|
||||
<th>Origin Points</th>
|
||||
<th>USD</th>
|
||||
<th>Available</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var deck in _decks)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
@if (!string.IsNullOrEmpty(deck.ImageCdnUrl))
|
||||
{
|
||||
<img src="@deck.ImageCdnUrl" alt="" style="width:40px;height:40px;object-fit:cover;border-radius:4px" />
|
||||
}
|
||||
<span class="fw-medium">@deck.Name</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-muted small">@(deck.ArchSpiritName ?? "—")</td>
|
||||
<td>@deck.Cards.Count</td>
|
||||
<td>@deck.OriginPointPrice.ToString("N0") OP</td>
|
||||
<td>@(deck.UsdPrice.HasValue ? $"${deck.UsdPrice:F2}" : "—")</td>
|
||||
<td class="small text-muted">@FormatWindow(deck.AvailableFrom, deck.AvailableUntil)</td>
|
||||
<td>
|
||||
@if (deck.IsActive && IsCurrentlyAvailable(deck))
|
||||
{
|
||||
<span class="badge bg-success">Live</span>
|
||||
}
|
||||
else if (deck.IsActive)
|
||||
{
|
||||
<span class="badge bg-warning text-dark">Active / Not in Window</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-secondary">Inactive</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<a href="/bazaar/decks/@deck.Id" class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-pencil"></i> Edit
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
private List<PrebuiltDeck>? _decks;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
=> _decks = await Db.PrebuiltDecks
|
||||
.Include(d => d.Cards)
|
||||
.OrderByDescending(d => d.CreatedAt)
|
||||
.ToListAsync();
|
||||
|
||||
private static string FormatWindow(DateTimeOffset? from, DateTimeOffset? until) =>
|
||||
(from, until) switch
|
||||
{
|
||||
(null, null) => "Always",
|
||||
({ } f, null) => $"From {f:yyyy-MM-dd}",
|
||||
(null, { } u) => $"Until {u:yyyy-MM-dd}",
|
||||
({ } f, { } u) => $"{f:yyyy-MM-dd} → {u:yyyy-MM-dd}",
|
||||
};
|
||||
|
||||
private static bool IsCurrentlyAvailable(PrebuiltDeck d)
|
||||
{
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
return (d.AvailableFrom == null || d.AvailableFrom <= now)
|
||||
&& (d.AvailableUntil == null || d.AvailableUntil >= now);
|
||||
}
|
||||
}
|
||||
@@ -5,27 +5,28 @@ using SOR.Database.Entities.Bazaar;
|
||||
using SOR.Database.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// EF Core DbContext for the bazaar schema: listings and transaction history.
|
||||
/// EF Core DbContext for the bazaar schema.
|
||||
///
|
||||
/// Schema: "bazaar"
|
||||
/// Run migrations: dotnet ef migrations add InitialCreate
|
||||
/// --context BazaarDbContext
|
||||
/// --project src/SOR.Database
|
||||
/// --startup-project src/SOR.Admin
|
||||
/// --output-dir Migrations/Bazaar
|
||||
/// Entities: BazaarListing, BazaarTransaction, BoosterPack, PrebuiltDeck, PrebuiltDeckCard
|
||||
/// </summary>
|
||||
public sealed class BazaarDbContext : DbContext
|
||||
{
|
||||
public BazaarDbContext(DbContextOptions<BazaarDbContext> options)
|
||||
: base(options) { }
|
||||
|
||||
public DbSet<BazaarListing> Listings => Set<BazaarListing>();
|
||||
public DbSet<BazaarListing> Listings => Set<BazaarListing>();
|
||||
public DbSet<BazaarTransaction> Transactions => Set<BazaarTransaction>();
|
||||
public DbSet<BoosterPack> BoosterPacks => Set<BoosterPack>();
|
||||
public DbSet<PrebuiltDeck> PrebuiltDecks => Set<PrebuiltDeck>();
|
||||
public DbSet<PrebuiltDeckCard> PrebuiltDeckCards => Set<PrebuiltDeckCard>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
builder.HasDefaultSchema("bazaar");
|
||||
|
||||
// ── P2P Listings ──────────────────────────────────────────────────────
|
||||
|
||||
builder.Entity<BazaarListing>(e =>
|
||||
{
|
||||
e.ToTable("listings");
|
||||
@@ -37,6 +38,7 @@ public sealed class BazaarDbContext : DbContext
|
||||
e.HasIndex(l => l.SellerAccountId);
|
||||
e.HasIndex(l => new { l.Status, l.CardDefinitionId });
|
||||
e.HasIndex(l => new { l.Status, l.ExpiresAt });
|
||||
// IsMasked: no special index needed — filtered at application level.
|
||||
e.HasMany(l => l.Transactions)
|
||||
.WithOne(t => t.Listing)
|
||||
.HasForeignKey(t => t.ListingId)
|
||||
@@ -53,5 +55,43 @@ public sealed class BazaarDbContext : DbContext
|
||||
e.HasIndex(t => t.SellerAccountId);
|
||||
e.HasIndex(t => t.TransactedAt);
|
||||
});
|
||||
|
||||
// ── Booster Packs ─────────────────────────────────────────────────────
|
||||
|
||||
builder.Entity<BoosterPack>(e =>
|
||||
{
|
||||
e.ToTable("booster_packs");
|
||||
e.HasKey(p => p.Id);
|
||||
e.Property(p => p.Name).HasMaxLength(200);
|
||||
e.Property(p => p.UsdPrice).HasColumnType("numeric(10,2)");
|
||||
// SlotsJson is stored as JSONB for flexible rarity distribution.
|
||||
e.Property(p => p.SlotsJson).HasColumnType("jsonb");
|
||||
e.HasIndex(p => p.IsActive);
|
||||
e.HasIndex(p => new { p.AvailableFrom, p.AvailableUntil });
|
||||
});
|
||||
|
||||
// ── Prebuilt Decks ────────────────────────────────────────────────────
|
||||
|
||||
builder.Entity<PrebuiltDeck>(e =>
|
||||
{
|
||||
e.ToTable("prebuilt_decks");
|
||||
e.HasKey(d => d.Id);
|
||||
e.Property(d => d.Name).HasMaxLength(200);
|
||||
e.Property(d => d.UsdPrice).HasColumnType("numeric(10,2)");
|
||||
e.HasIndex(d => d.IsActive);
|
||||
e.HasMany(d => d.Cards)
|
||||
.WithOne(c => c.PrebuiltDeck)
|
||||
.HasForeignKey(c => c.PrebuiltDeckId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
builder.Entity<PrebuiltDeckCard>(e =>
|
||||
{
|
||||
e.ToTable("prebuilt_deck_cards");
|
||||
e.HasKey(c => c.Id);
|
||||
e.Property(c => c.CardName).HasMaxLength(200);
|
||||
// One entry per card per deck.
|
||||
e.HasIndex(c => new { c.PrebuiltDeckId, c.CardDefinitionId }).IsUnique();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,19 @@ public sealed class BazaarListing
|
||||
|
||||
public BazaarListingType ListingType { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public BazaarCurrency Currency { get; set; }
|
||||
|
||||
/// <summary>Players may only list for origin points (Gold). USD is reserved for store products.</summary>
|
||||
public BazaarCurrency Currency { get; set; } = BazaarCurrency.Gold;
|
||||
|
||||
public DateTimeOffset ListedAt { get; set; }
|
||||
public DateTimeOffset? ExpiresAt { get; set; }
|
||||
public BazaarListingStatus Status { get; set; } = BazaarListingStatus.Active;
|
||||
|
||||
/// <summary>
|
||||
/// When true, the card's identity (name, art, specific definition) is hidden from buyers.
|
||||
/// Buyers see only the rarity and card type — a blind/mystery listing.
|
||||
/// </summary>
|
||||
public bool IsMasked { get; set; }
|
||||
|
||||
public ICollection<BazaarTransaction> Transactions { get; set; } = new List<BazaarTransaction>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
namespace SOR.Database.Entities.Bazaar;
|
||||
|
||||
/// <summary>
|
||||
/// A purchasable booster pack product.
|
||||
///
|
||||
/// SlotsJson defines the card distribution as a JSONB array:
|
||||
/// [{"rarity":"Common","count":5},{"rarity":"Rare","count":2},{"rarity":"Legendary","count":1}]
|
||||
/// When a player opens a pack the server draws randomly from eligible card pools per slot.
|
||||
///
|
||||
/// Dual-currency pricing:
|
||||
/// OriginPointPrice — in-game earned currency, always set.
|
||||
/// UsdPrice — real-money price; null if not available for direct purchase.
|
||||
///
|
||||
/// Availability is controlled by AvailableFrom / AvailableUntil:
|
||||
/// null/null → no time restriction (always available while IsActive)
|
||||
/// From only → available from that date onward
|
||||
/// Until only → available until that date
|
||||
/// Both → available only within that window
|
||||
/// </summary>
|
||||
public sealed class BoosterPack
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string? Description { get; set; }
|
||||
public string? ImageCdnUrl { get; set; }
|
||||
|
||||
/// <summary>Cost in origin points (in-game earned currency).</summary>
|
||||
public int OriginPointPrice { get; set; }
|
||||
|
||||
/// <summary>Cost in USD. Null if not sold for real money.</summary>
|
||||
public decimal? UsdPrice { get; set; }
|
||||
|
||||
public DateTimeOffset? AvailableFrom { get; set; }
|
||||
public DateTimeOffset? AvailableUntil { get; set; }
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// JSONB slot distribution, e.g.:
|
||||
/// [{"rarity":"Common","count":5},{"rarity":"Rare","count":2},{"rarity":"Legendary","count":1}]
|
||||
/// </summary>
|
||||
public string? SlotsJson { get; set; }
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace SOR.Database.Entities.Bazaar;
|
||||
|
||||
/// <summary>
|
||||
/// A purchasable prebuilt deck product.
|
||||
///
|
||||
/// Contains a curated list of cards (PrebuiltDeckCard) and a designated ArchSpirit.
|
||||
/// Players purchase the deck and receive all cards as PlayerCard instances.
|
||||
///
|
||||
/// Cross-schema references (ArchSpiritCardDefinitionId, cards) are bare Guids — no EF FKs.
|
||||
/// </summary>
|
||||
public sealed class PrebuiltDeck
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string? Description { get; set; }
|
||||
public string? ImageCdnUrl { get; set; }
|
||||
|
||||
/// <summary>Cost in origin points.</summary>
|
||||
public int OriginPointPrice { get; set; }
|
||||
|
||||
/// <summary>Cost in USD. Null if not sold for real money.</summary>
|
||||
public decimal? UsdPrice { get; set; }
|
||||
|
||||
public DateTimeOffset? AvailableFrom { get; set; }
|
||||
public DateTimeOffset? AvailableUntil { get; set; }
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
/// <summary>Cross-schema: the ArchSpirit card included in this deck. Bare Guid.</summary>
|
||||
public Guid? ArchSpiritCardDefinitionId { get; set; }
|
||||
|
||||
/// <summary>Denormalized display name of the ArchSpirit — avoids cross-context lookups.</summary>
|
||||
public string? ArchSpiritName { get; set; }
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
|
||||
public ICollection<PrebuiltDeckCard> Cards { get; set; } = new List<PrebuiltDeckCard>();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace SOR.Database.Entities.Bazaar;
|
||||
|
||||
/// <summary>
|
||||
/// A card entry in a PrebuiltDeck.
|
||||
///
|
||||
/// CardDefinitionId is a bare cross-schema Guid (no EF FK to catalog schema).
|
||||
/// CardName is denormalized to avoid cross-DbContext lookups during display.
|
||||
/// </summary>
|
||||
public sealed class PrebuiltDeckCard
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public Guid PrebuiltDeckId { get; set; }
|
||||
public PrebuiltDeck PrebuiltDeck { get; set; } = null!;
|
||||
|
||||
/// <summary>Cross-schema: the card definition. Bare Guid, no EF FK.</summary>
|
||||
public Guid CardDefinitionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Denormalized card name for display without querying the catalog DbContext.
|
||||
/// Updated when the card editor saves a name change.
|
||||
/// </summary>
|
||||
public string CardName { get; set; } = string.Empty;
|
||||
|
||||
public int Quantity { get; set; } = 1;
|
||||
}
|
||||
Generated
+283
@@ -0,0 +1,283 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using SOR.Database.Contexts;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SOR.Database.Migrations.Bazaar
|
||||
{
|
||||
[DbContext(typeof(BazaarDbContext))]
|
||||
[Migration("20260225145541_AddBazaarStoreProducts")]
|
||||
partial class AddBazaarStoreProducts
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasDefaultSchema("bazaar")
|
||||
.HasAnnotation("ProductVersion", "8.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarListing", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("CardDefinitionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Currency")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTimeOffset?>("ExpiresAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<bool>("IsMasked")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTimeOffset>("ListedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ListingType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("PlayerCardId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("numeric(18,4)");
|
||||
|
||||
b.Property<Guid>("SellerAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SellerAccountId");
|
||||
|
||||
b.HasIndex("Status", "CardDefinitionId");
|
||||
|
||||
b.HasIndex("Status", "ExpiresAt");
|
||||
|
||||
b.ToTable("listings", "bazaar");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarTransaction", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<decimal>("Amount")
|
||||
.HasColumnType("numeric(18,4)");
|
||||
|
||||
b.Property<Guid>("BuyerAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Currency")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("ListingId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("PlayerCardId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SellerAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("TransactedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuyerAccountId");
|
||||
|
||||
b.HasIndex("ListingId");
|
||||
|
||||
b.HasIndex("SellerAccountId");
|
||||
|
||||
b.HasIndex("TransactedAt");
|
||||
|
||||
b.ToTable("transactions", "bazaar");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BoosterPack", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset?>("AvailableFrom")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("AvailableUntil")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ImageCdnUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)");
|
||||
|
||||
b.Property<int>("OriginPointPrice")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("SlotsJson")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<decimal?>("UsdPrice")
|
||||
.HasColumnType("numeric(10,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
b.HasIndex("AvailableFrom", "AvailableUntil");
|
||||
|
||||
b.ToTable("booster_packs", "bazaar");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeck", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("ArchSpiritCardDefinitionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("ArchSpiritName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTimeOffset?>("AvailableFrom")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("AvailableUntil")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ImageCdnUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)");
|
||||
|
||||
b.Property<int>("OriginPointPrice")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<decimal?>("UsdPrice")
|
||||
.HasColumnType("numeric(10,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
b.ToTable("prebuilt_decks", "bazaar");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeckCard", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("CardDefinitionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("CardName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)");
|
||||
|
||||
b.Property<Guid>("PrebuiltDeckId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PrebuiltDeckId", "CardDefinitionId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("prebuilt_deck_cards", "bazaar");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarTransaction", b =>
|
||||
{
|
||||
b.HasOne("SOR.Database.Entities.Bazaar.BazaarListing", "Listing")
|
||||
.WithMany("Transactions")
|
||||
.HasForeignKey("ListingId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Listing");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeckCard", b =>
|
||||
{
|
||||
b.HasOne("SOR.Database.Entities.Bazaar.PrebuiltDeck", "PrebuiltDeck")
|
||||
.WithMany("Cards")
|
||||
.HasForeignKey("PrebuiltDeckId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PrebuiltDeck");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarListing", b =>
|
||||
{
|
||||
b.Navigation("Transactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeck", b =>
|
||||
{
|
||||
b.Navigation("Cards");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SOR.Database.Migrations.Bazaar
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddBazaarStoreProducts : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsMasked",
|
||||
schema: "bazaar",
|
||||
table: "listings",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "booster_packs",
|
||||
schema: "bazaar",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
||||
Description = table.Column<string>(type: "text", nullable: true),
|
||||
ImageCdnUrl = table.Column<string>(type: "text", nullable: true),
|
||||
OriginPointPrice = table.Column<int>(type: "integer", nullable: false),
|
||||
UsdPrice = table.Column<decimal>(type: "numeric(10,2)", nullable: true),
|
||||
AvailableFrom = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
AvailableUntil = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
||||
SlotsJson = table.Column<string>(type: "jsonb", nullable: true),
|
||||
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_booster_packs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "prebuilt_decks",
|
||||
schema: "bazaar",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
||||
Description = table.Column<string>(type: "text", nullable: true),
|
||||
ImageCdnUrl = table.Column<string>(type: "text", nullable: true),
|
||||
OriginPointPrice = table.Column<int>(type: "integer", nullable: false),
|
||||
UsdPrice = table.Column<decimal>(type: "numeric(10,2)", nullable: true),
|
||||
AvailableFrom = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
AvailableUntil = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
||||
ArchSpiritCardDefinitionId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
ArchSpiritName = table.Column<string>(type: "text", nullable: true),
|
||||
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_prebuilt_decks", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "prebuilt_deck_cards",
|
||||
schema: "bazaar",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
PrebuiltDeckId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CardDefinitionId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CardName = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
||||
Quantity = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_prebuilt_deck_cards", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_prebuilt_deck_cards_prebuilt_decks_PrebuiltDeckId",
|
||||
column: x => x.PrebuiltDeckId,
|
||||
principalSchema: "bazaar",
|
||||
principalTable: "prebuilt_decks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_booster_packs_AvailableFrom_AvailableUntil",
|
||||
schema: "bazaar",
|
||||
table: "booster_packs",
|
||||
columns: new[] { "AvailableFrom", "AvailableUntil" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_booster_packs_IsActive",
|
||||
schema: "bazaar",
|
||||
table: "booster_packs",
|
||||
column: "IsActive");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_prebuilt_deck_cards_PrebuiltDeckId_CardDefinitionId",
|
||||
schema: "bazaar",
|
||||
table: "prebuilt_deck_cards",
|
||||
columns: new[] { "PrebuiltDeckId", "CardDefinitionId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_prebuilt_decks_IsActive",
|
||||
schema: "bazaar",
|
||||
table: "prebuilt_decks",
|
||||
column: "IsActive");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "booster_packs",
|
||||
schema: "bazaar");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "prebuilt_deck_cards",
|
||||
schema: "bazaar");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "prebuilt_decks",
|
||||
schema: "bazaar");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsMasked",
|
||||
schema: "bazaar",
|
||||
table: "listings");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,9 @@ namespace SOR.Database.Migrations.Bazaar
|
||||
b.Property<DateTimeOffset?>("ExpiresAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<bool>("IsMasked")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTimeOffset>("ListedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
@@ -111,6 +114,135 @@ namespace SOR.Database.Migrations.Bazaar
|
||||
b.ToTable("transactions", "bazaar");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BoosterPack", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset?>("AvailableFrom")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("AvailableUntil")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ImageCdnUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)");
|
||||
|
||||
b.Property<int>("OriginPointPrice")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("SlotsJson")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<decimal?>("UsdPrice")
|
||||
.HasColumnType("numeric(10,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
b.HasIndex("AvailableFrom", "AvailableUntil");
|
||||
|
||||
b.ToTable("booster_packs", "bazaar");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeck", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("ArchSpiritCardDefinitionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("ArchSpiritName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTimeOffset?>("AvailableFrom")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("AvailableUntil")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ImageCdnUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)");
|
||||
|
||||
b.Property<int>("OriginPointPrice")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<decimal?>("UsdPrice")
|
||||
.HasColumnType("numeric(10,2)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
b.ToTable("prebuilt_decks", "bazaar");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeckCard", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("CardDefinitionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("CardName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)");
|
||||
|
||||
b.Property<Guid>("PrebuiltDeckId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PrebuiltDeckId", "CardDefinitionId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("prebuilt_deck_cards", "bazaar");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarTransaction", b =>
|
||||
{
|
||||
b.HasOne("SOR.Database.Entities.Bazaar.BazaarListing", "Listing")
|
||||
@@ -122,10 +254,26 @@ namespace SOR.Database.Migrations.Bazaar
|
||||
b.Navigation("Listing");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeckCard", b =>
|
||||
{
|
||||
b.HasOne("SOR.Database.Entities.Bazaar.PrebuiltDeck", "PrebuiltDeck")
|
||||
.WithMany("Cards")
|
||||
.HasForeignKey("PrebuiltDeckId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PrebuiltDeck");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarListing", b =>
|
||||
{
|
||||
b.Navigation("Transactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Bazaar.PrebuiltDeck", b =>
|
||||
{
|
||||
b.Navigation("Cards");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user