Topup functions

This commit is contained in:
2023-07-04 14:11:53 +01:00
parent 013008dcf9
commit 00c918b1f6
17 changed files with 6519 additions and 12 deletions

View File

@ -7,11 +7,21 @@ public class PaymentsConfiguration : IEntityTypeConfiguration<Payment>
{
public void Configure(EntityTypeBuilder<Payment> builder)
{
builder.HasKey(a => a.PubKey);
builder.HasKey(a => a.PaymentHash);
builder.Property(a => a.Invoice)
.IsRequired();
builder.Property(a => a.IsPaid)
.IsRequired();
builder.Property(a => a.Amount)
.IsRequired();
builder.Property(a => a.Created)
.IsRequired();
builder.HasOne(a => a.User)
.WithMany(a => a.Payments)
.HasForeignKey(a => a.PubKey);
}
}

View File

@ -14,5 +14,8 @@ public class UserConfiguration : IEntityTypeConfiguration<User>
builder.Property(a => a.Event);
builder.Property(a => a.Balance)
.IsRequired();
builder.Property(a => a.Version)
.IsRowVersion();
}
}

View File

@ -2,9 +2,16 @@ namespace NostrStreamer.Database;
public class Payment
{
public string PaymentHash { get; init; } = null!;
public string PubKey { get; init; } = null!;
public User User { get; init; } = null!;
public string Invoice { get; init; } = null!;
public bool IsPaid { get; init; }
public bool IsPaid { get; set; }
public ulong Amount { get; init; }
public DateTime Created { get; init; } = DateTime.UtcNow;
}

View File

@ -38,4 +38,11 @@ public class User
/// Comma seperated tags
/// </summary>
public string? Tags { get; set; }
/// <summary>
/// Concurrency token
/// </summary>
public uint Version { get; set; }
public List<Payment> Payments { get; init; } = new();
}