This commit is contained in:
2023-06-30 14:08:15 +01:00
commit bcaa32afb1
28 changed files with 1109 additions and 0 deletions

View File

@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace NostrStreamer.Database.Configuration;
public class PaymentsConfiguration : IEntityTypeConfiguration<Payment>
{
public void Configure(EntityTypeBuilder<Payment> builder)
{
builder.HasKey(a => a.PubKey);
builder.Property(a => a.Invoice)
.IsRequired();
builder.Property(a => a.IsPaid)
.IsRequired();
}
}

View File

@ -0,0 +1,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace NostrStreamer.Database.Configuration;
public class UserConfiguration : IEntityTypeConfiguration<User>
{
public void Configure(EntityTypeBuilder<User> builder)
{
builder.HasKey(a => a.PubKey);
builder.Property(a => a.StreamKey)
.IsRequired();
builder.Property(a => a.Event);
builder.Property(a => a.Balance)
.IsRequired();
}
}

View File

@ -0,0 +1,10 @@
namespace NostrStreamer.Database;
public class Payment
{
public string PubKey { get; init; } = null!;
public string Invoice { get; init; } = null!;
public bool IsPaid { get; init; }
}

View File

@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
namespace NostrStreamer.Database;
public class StreamerContext : DbContext
{
public StreamerContext()
{
}
public StreamerContext(DbContextOptions<StreamerContext> ctx) : base(ctx)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(StreamerContext).Assembly);
}
public DbSet<User> Users => Set<User>();
public DbSet<Payment> Payments => Set<Payment>();
}

View File

@ -0,0 +1,41 @@
namespace NostrStreamer.Database;
public class User
{
public string PubKey { get; init; } = null!;
/// <summary>
/// Stream key
/// </summary>
public string StreamKey { get; init; } = null!;
/// <summary>
/// Most recent nostr event published
/// </summary>
public string? Event { get; init; }
/// <summary>
/// Sats balance
/// </summary>
public long Balance { get; init; }
/// <summary>
/// Stream title
/// </summary>
public string? Title { get; init; }
/// <summary>
/// Stream summary
/// </summary>
public string? Summary { get; init; }
/// <summary>
/// Stream cover image
/// </summary>
public string? Image { get; init; }
/// <summary>
/// Comma seperated tags
/// </summary>
public string? Tags { get; init; }
}