mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-03 17:36:59 +01:00
Refactoring Data entities to fit one standard convention
This commit is contained in:
parent
91cb9129ab
commit
c9dc60be7b
28 changed files with 173 additions and 387 deletions
|
@ -6,15 +6,13 @@ namespace BTCPayServer.Data
|
||||||
public class APIKeyData
|
public class APIKeyData
|
||||||
{
|
{
|
||||||
[MaxLength(50)]
|
[MaxLength(50)]
|
||||||
public string Id
|
public string Id { get; set; }
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
[MaxLength(50)] public string StoreId { get; set; }
|
[MaxLength(50)]
|
||||||
|
public string StoreId { get; set; }
|
||||||
|
|
||||||
[MaxLength(50)] public string UserId { get; set; }
|
[MaxLength(50)]
|
||||||
|
public string UserId { get; set; }
|
||||||
|
|
||||||
public APIKeyType Type { get; set; } = APIKeyType.Legacy;
|
public APIKeyType Type { get; set; } = APIKeyType.Legacy;
|
||||||
|
|
||||||
|
@ -23,6 +21,7 @@ namespace BTCPayServer.Data
|
||||||
public ApplicationUser User { get; set; }
|
public ApplicationUser User { get; set; }
|
||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<APIKeyData>()
|
builder.Entity<APIKeyData>()
|
||||||
|
|
|
@ -10,25 +10,11 @@ namespace BTCPayServer.Data
|
||||||
/// For not having exceptions thrown by two address on different network, we suffix by "#CRYPTOCODE"
|
/// For not having exceptions thrown by two address on different network, we suffix by "#CRYPTOCODE"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Use GetHash instead")]
|
[Obsolete("Use GetHash instead")]
|
||||||
public string Address
|
public string Address { get; set; }
|
||||||
{
|
public InvoiceData InvoiceData { get; set; }
|
||||||
get; set;
|
public string InvoiceDataId { get; set; }
|
||||||
}
|
public DateTimeOffset? CreatedTime { get; set; }
|
||||||
|
|
||||||
public InvoiceData InvoiceData
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string InvoiceDataId
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTimeOffset? CreatedTime
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,22 +8,24 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string StoreDataId
|
public string StoreDataId { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public string AppType { get; set; }
|
public string AppType { get; set; }
|
||||||
public StoreData StoreData
|
public StoreData StoreData { get; set; }
|
||||||
{
|
public DateTimeOffset Created { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public DateTimeOffset Created
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public bool TagAllInvoices { get; set; }
|
public bool TagAllInvoices { get; set; }
|
||||||
public string Settings { get; set; }
|
public string Settings { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Entity<AppData>()
|
||||||
|
.HasOne(o => o.StoreData)
|
||||||
|
.WithMany(i => i.Apps).OnDelete(DeleteBehavior.Cascade);
|
||||||
|
builder.Entity<AppData>()
|
||||||
|
.HasOne(a => a.StoreData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// utility methods
|
||||||
public T GetSettings<T>() where T : class, new()
|
public T GetSettings<T>() where T : class, new()
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(Settings))
|
if (String.IsNullOrEmpty(Settings))
|
||||||
|
@ -35,14 +37,5 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
Settings = value == null ? null : JsonConvert.SerializeObject(value);
|
Settings = value == null ? null : JsonConvert.SerializeObject(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
|
||||||
{
|
|
||||||
builder.Entity<AppData>()
|
|
||||||
.HasOne(o => o.StoreData)
|
|
||||||
.WithMany(i => i.Apps).OnDelete(DeleteBehavior.Cascade);
|
|
||||||
builder.Entity<AppData>()
|
|
||||||
.HasOne(a => a.StoreData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,15 +30,8 @@ namespace BTCPayServer.Data
|
||||||
_designTime = designTime;
|
_designTime = designTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbSet<InvoiceData> Invoices
|
public DbSet<InvoiceData> Invoices { get; set; }
|
||||||
{
|
public DbSet<RefundData> Refunds { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public DbSet<RefundData> Refunds
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DbSet<PlannedTransaction> PlannedTransactions { get; set; }
|
public DbSet<PlannedTransaction> PlannedTransactions { get; set; }
|
||||||
public DbSet<PayjoinLock> PayjoinLocks { get; set; }
|
public DbSet<PayjoinLock> PayjoinLocks { get; set; }
|
||||||
public DbSet<AppData> Apps { get; set; }
|
public DbSet<AppData> Apps { get; set; }
|
||||||
|
@ -84,7 +77,6 @@ namespace BTCPayServer.Data
|
||||||
InvoiceData.OnModelCreating(builder);
|
InvoiceData.OnModelCreating(builder);
|
||||||
InvoiceSearchData.OnModelCreating(builder);
|
InvoiceSearchData.OnModelCreating(builder);
|
||||||
PaymentData.OnModelCreating(builder);
|
PaymentData.OnModelCreating(builder);
|
||||||
Data.UserStore.OnModelCreating(builder);
|
|
||||||
APIKeyData.OnModelCreating(builder);
|
APIKeyData.OnModelCreating(builder);
|
||||||
AppData.OnModelCreating(builder);
|
AppData.OnModelCreating(builder);
|
||||||
AddressInvoiceData.OnModelCreating(builder);
|
AddressInvoiceData.OnModelCreating(builder);
|
||||||
|
|
|
@ -7,27 +7,14 @@ namespace BTCPayServer.Data
|
||||||
// Add profile data for application users by adding properties to the ApplicationUser class
|
// Add profile data for application users by adding properties to the ApplicationUser class
|
||||||
public class ApplicationUser : IdentityUser
|
public class ApplicationUser : IdentityUser
|
||||||
{
|
{
|
||||||
public List<NotificationData> Notifications { get; set; }
|
public bool RequiresEmailConfirmation { get; set; }
|
||||||
public List<UserStore> UserStores
|
public List<StoredFile> StoredFiles { get; set; }
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool RequiresEmailConfirmation
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<StoredFile> StoredFiles
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<U2FDevice> U2FDevices { get; set; }
|
public List<U2FDevice> U2FDevices { get; set; }
|
||||||
public List<APIKeyData> APIKeys { get; set; }
|
public List<APIKeyData> APIKeys { get; set; }
|
||||||
public DateTimeOffset? Created { get; set; }
|
public DateTimeOffset? Created { get; set; }
|
||||||
public string DisabledNotifications { get; set; }
|
public string DisabledNotifications { get; set; }
|
||||||
|
|
||||||
|
public List<NotificationData> Notifications { get; set; }
|
||||||
|
public List<UserStore> UserStores { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,39 +5,23 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public class HistoricalAddressInvoiceData
|
public class HistoricalAddressInvoiceData
|
||||||
{
|
{
|
||||||
public string InvoiceDataId
|
public string InvoiceDataId { get; set; }
|
||||||
{
|
public InvoiceData InvoiceData { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InvoiceData InvoiceData
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Some crypto currencies share same address prefix
|
/// Some crypto currencies share same address prefix
|
||||||
/// For not having exceptions thrown by two address on different network, we suffix by "#CRYPTOCODE"
|
/// For not having exceptions thrown by two address on different network, we suffix by "#CRYPTOCODE"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Use GetCryptoCode instead")]
|
[Obsolete("Use GetCryptoCode instead")]
|
||||||
public string Address
|
public string Address { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Obsolete("Use GetCryptoCode instead")]
|
[Obsolete("Use GetCryptoCode instead")]
|
||||||
public string CryptoCode { get; set; }
|
public string CryptoCode { get; set; }
|
||||||
|
|
||||||
public DateTimeOffset Assigned
|
public DateTimeOffset Assigned { get; set; }
|
||||||
{
|
public DateTimeOffset? UnAssigned { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTimeOffset? UnAssigned
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,72 +7,24 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public class InvoiceData
|
public class InvoiceData
|
||||||
{
|
{
|
||||||
public string StoreDataId
|
public string Id { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public StoreData StoreData
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Id
|
public string StoreDataId { get; set; }
|
||||||
{
|
public StoreData StoreData { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTimeOffset Created
|
public DateTimeOffset Created { get; set; }
|
||||||
{
|
public List<PaymentData> Payments { get; set; }
|
||||||
get; set;
|
public List<InvoiceEventData> Events { get; set; }
|
||||||
}
|
|
||||||
public List<PaymentData> Payments
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InvoiceEventData> Events
|
public List<HistoricalAddressInvoiceData> HistoricalAddressInvoices { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<HistoricalAddressInvoiceData> HistoricalAddressInvoices
|
public byte[] Blob { get; set; }
|
||||||
{
|
public string ItemCode { get; set; }
|
||||||
get; set;
|
public string OrderId { get; set; }
|
||||||
}
|
public string Status { get; set; }
|
||||||
|
public string ExceptionStatus { get; set; }
|
||||||
public byte[] Blob
|
public string CustomerEmail { get; set; }
|
||||||
{
|
public List<AddressInvoiceData> AddressInvoices { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public string ItemCode
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
public string OrderId
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
public string Status
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
public string ExceptionStatus
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
public string CustomerEmail
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
public List<AddressInvoiceData> AddressInvoices
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public bool Archived { get; set; }
|
public bool Archived { get; set; }
|
||||||
public List<PendingInvoiceData> PendingInvoices { get; set; }
|
public List<PendingInvoiceData> PendingInvoices { get; set; }
|
||||||
public List<InvoiceSearchData> InvoiceSearchData { get; set; }
|
public List<InvoiceSearchData> InvoiceSearchData { get; set; }
|
||||||
|
@ -80,6 +32,8 @@ namespace BTCPayServer.Data
|
||||||
public string CurrentRefundId { get; set; }
|
public string CurrentRefundId { get; set; }
|
||||||
[ForeignKey("Id,CurrentRefundId")]
|
[ForeignKey("Id,CurrentRefundId")]
|
||||||
public RefundData CurrentRefund { get; set; }
|
public RefundData CurrentRefund { get; set; }
|
||||||
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<InvoiceData>()
|
builder.Entity<InvoiceData>()
|
||||||
|
|
|
@ -5,23 +5,14 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public class InvoiceEventData
|
public class InvoiceEventData
|
||||||
{
|
{
|
||||||
public string InvoiceDataId
|
public string InvoiceDataId { get; set; }
|
||||||
{
|
public InvoiceData InvoiceData { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public InvoiceData InvoiceData
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public string UniqueId { get; set; }
|
public string UniqueId { get; set; }
|
||||||
public DateTimeOffset Timestamp
|
public DateTimeOffset Timestamp { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
public EventSeverity Severity { get; set; } = EventSeverity.Info;
|
public EventSeverity Severity { get; set; } = EventSeverity.Info;
|
||||||
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<InvoiceEventData>()
|
builder.Entity<InvoiceEventData>()
|
||||||
|
@ -36,7 +27,7 @@ namespace BTCPayServer.Data
|
||||||
#pragma warning restore CS0618
|
#pragma warning restore CS0618
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum EventSeverity
|
public enum EventSeverity
|
||||||
{
|
{
|
||||||
Info,
|
Info,
|
||||||
|
@ -44,7 +35,7 @@ namespace BTCPayServer.Data
|
||||||
Success,
|
Success,
|
||||||
Warning
|
Warning
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetCssClass()
|
public string GetCssClass()
|
||||||
{
|
{
|
||||||
return Severity switch
|
return Severity switch
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
namespace BTCPayServer.Data
|
namespace BTCPayServer.Data
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace BTCPayServer.Data
|
namespace BTCPayServer.Data
|
||||||
|
@ -11,6 +8,8 @@ namespace BTCPayServer.Data
|
||||||
public InvoiceData Invoice { get; set; }
|
public InvoiceData Invoice { get; set; }
|
||||||
public string DeliveryId { get; set; }
|
public string DeliveryId { get; set; }
|
||||||
public WebhookDeliveryData Delivery { get; set; }
|
public WebhookDeliveryData Delivery { get; set; }
|
||||||
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<InvoiceWebhookDeliveryData>()
|
builder.Entity<InvoiceWebhookDeliveryData>()
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace BTCPayServer.Data
|
||||||
public bool Seen { get; set; }
|
public bool Seen { get; set; }
|
||||||
public byte[] Blob { get; set; }
|
public byte[] Blob { get; set; }
|
||||||
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<NotificationData>()
|
builder.Entity<NotificationData>()
|
||||||
|
|
|
@ -5,32 +5,16 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public class PairedSINData
|
public class PairedSINData
|
||||||
{
|
{
|
||||||
public string Id
|
public string Id { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string StoreDataId
|
public string StoreDataId { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StoreData StoreData { get; set; }
|
public StoreData StoreData { get; set; }
|
||||||
|
|
||||||
public string Label
|
public string Label { get; set; }
|
||||||
{
|
public DateTimeOffset PairingTime { get; set; }
|
||||||
get;
|
public string SIN { get; set; }
|
||||||
set;
|
|
||||||
}
|
|
||||||
public DateTimeOffset PairingTime
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
public string SIN
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,45 +5,17 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public class PairingCodeData
|
public class PairingCodeData
|
||||||
{
|
{
|
||||||
public string Id
|
public string Id { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
[Obsolete("Unused")]
|
[Obsolete("Unused")]
|
||||||
public string Facade
|
public string Facade { get; set; }
|
||||||
{
|
public string StoreDataId { get; set; }
|
||||||
get; set;
|
public DateTimeOffset Expiration { get; set; }
|
||||||
}
|
|
||||||
public string StoreDataId
|
public string Label { get; set; }
|
||||||
{
|
public string SIN { get; set; }
|
||||||
get; set;
|
public DateTime DateCreated { get; set; }
|
||||||
}
|
public string TokenValue { get; set; }
|
||||||
public DateTimeOffset Expiration
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Label
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
public string SIN
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
public DateTime DateCreated
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
public string TokenValue
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,28 +4,13 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public class PaymentData
|
public class PaymentData
|
||||||
{
|
{
|
||||||
public string Id
|
public string Id { get; set; }
|
||||||
{
|
public string InvoiceDataId { get; set; }
|
||||||
get; set;
|
public InvoiceData InvoiceData { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public string InvoiceDataId
|
public byte[] Blob { get; set; }
|
||||||
{
|
public bool Accounted { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public InvoiceData InvoiceData
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] Blob
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public bool Accounted
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,10 +6,7 @@ namespace BTCPayServer.Data
|
||||||
public class PaymentRequestData
|
public class PaymentRequestData
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public DateTimeOffset Created
|
public DateTimeOffset Created { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public string StoreDataId { get; set; }
|
public string StoreDataId { get; set; }
|
||||||
public bool Archived { get; set; }
|
public bool Archived { get; set; }
|
||||||
|
|
||||||
|
@ -19,6 +16,7 @@ namespace BTCPayServer.Data
|
||||||
|
|
||||||
public byte[] Blob { get; set; }
|
public byte[] Blob { get; set; }
|
||||||
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<PaymentRequestData>()
|
builder.Entity<PaymentRequestData>()
|
||||||
|
|
|
@ -21,18 +21,7 @@ namespace BTCPayServer.Data
|
||||||
public string Destination { get; set; }
|
public string Destination { get; set; }
|
||||||
public byte[] Blob { get; set; }
|
public byte[] Blob { get; set; }
|
||||||
public byte[] Proof { get; set; }
|
public byte[] Proof { get; set; }
|
||||||
public bool IsInPeriod(PullPaymentData pp, DateTimeOffset now)
|
|
||||||
{
|
|
||||||
var period = pp.GetPeriod(now);
|
|
||||||
if (period is { } p)
|
|
||||||
{
|
|
||||||
return p.Start <= Date && (p.End is DateTimeOffset end ? Date < end : true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +38,20 @@ namespace BTCPayServer.Data
|
||||||
builder.Entity<PayoutData>()
|
builder.Entity<PayoutData>()
|
||||||
.HasIndex(o => o.State);
|
.HasIndex(o => o.State);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// utility methods
|
||||||
|
public bool IsInPeriod(PullPaymentData pp, DateTimeOffset now)
|
||||||
|
{
|
||||||
|
var period = pp.GetPeriod(now);
|
||||||
|
if (period is { } p)
|
||||||
|
{
|
||||||
|
return p.Start <= Date && (p.End is DateTimeOffset end ? Date < end : true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PayoutState
|
public enum PayoutState
|
||||||
|
|
|
@ -4,10 +4,7 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public class PendingInvoiceData
|
public class PendingInvoiceData
|
||||||
{
|
{
|
||||||
public string Id
|
public string Id { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public InvoiceData InvoiceData { get; set; }
|
public InvoiceData InvoiceData { get; set; }
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
|
|
|
@ -7,8 +7,7 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
[MaxLength(100)]
|
[MaxLength(100)]
|
||||||
// Id in the format [cryptocode]-[txid]
|
public string Id { get; set; } // Id in the format [cryptocode]-[txid]
|
||||||
public string Id { get; set; }
|
|
||||||
public DateTimeOffset BroadcastAt { get; set; }
|
public DateTimeOffset BroadcastAt { get; set; }
|
||||||
public byte[] Blob { get; set; }
|
public byte[] Blob { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,53 +8,6 @@ using NBitcoin;
|
||||||
|
|
||||||
namespace BTCPayServer.Data
|
namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public static class PayoutExtensions
|
|
||||||
{
|
|
||||||
public static IQueryable<PayoutData> GetPayoutInPeriod(this IQueryable<PayoutData> payouts, PullPaymentData pp)
|
|
||||||
{
|
|
||||||
return GetPayoutInPeriod(payouts, pp, DateTimeOffset.UtcNow);
|
|
||||||
}
|
|
||||||
public static IQueryable<PayoutData> GetPayoutInPeriod(this IQueryable<PayoutData> payouts, PullPaymentData pp, DateTimeOffset now)
|
|
||||||
{
|
|
||||||
var request = payouts.Where(p => p.PullPaymentDataId == pp.Id);
|
|
||||||
var period = pp.GetPeriod(now);
|
|
||||||
if (period is { } p)
|
|
||||||
{
|
|
||||||
var start = p.Start;
|
|
||||||
if (p.End is DateTimeOffset end)
|
|
||||||
{
|
|
||||||
return request.Where(p => p.Date >= start && p.Date < end);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return request.Where(p => p.Date >= start);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return request.Where(p => false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetStateString(this PayoutState state)
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case PayoutState.AwaitingApproval:
|
|
||||||
return "Awaiting Approval";
|
|
||||||
case PayoutState.AwaitingPayment:
|
|
||||||
return "Awaiting Payment";
|
|
||||||
case PayoutState.InProgress:
|
|
||||||
return "In Progress";
|
|
||||||
case PayoutState.Completed:
|
|
||||||
return "Completed";
|
|
||||||
case PayoutState.Cancelled:
|
|
||||||
return "Cancelled";
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(state), state, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class PullPaymentData
|
public class PullPaymentData
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
|
@ -71,6 +24,16 @@ namespace BTCPayServer.Data
|
||||||
public List<PayoutData> Payouts { get; set; }
|
public List<PayoutData> Payouts { get; set; }
|
||||||
public byte[] Blob { get; set; }
|
public byte[] Blob { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Entity<PullPaymentData>()
|
||||||
|
.HasIndex(o => o.StoreId);
|
||||||
|
builder.Entity<PullPaymentData>()
|
||||||
|
.HasOne(o => o.StoreData)
|
||||||
|
.WithMany(o => o.PullPayments).OnDelete(DeleteBehavior.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
public (DateTimeOffset Start, DateTimeOffset? End)? GetPeriod(DateTimeOffset now)
|
public (DateTimeOffset Start, DateTimeOffset? End)? GetPeriod(DateTimeOffset now)
|
||||||
{
|
{
|
||||||
if (now < StartDate)
|
if (now < StartDate)
|
||||||
|
@ -121,14 +84,54 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
return !Archived && !IsExpired(now) && HasStarted(now);
|
return !Archived && !IsExpired(now) && HasStarted(now);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
|
||||||
|
public static class PayoutExtensions
|
||||||
|
{
|
||||||
|
public static IQueryable<PayoutData> GetPayoutInPeriod(this IQueryable<PayoutData> payouts, PullPaymentData pp)
|
||||||
{
|
{
|
||||||
builder.Entity<PullPaymentData>()
|
return GetPayoutInPeriod(payouts, pp, DateTimeOffset.UtcNow);
|
||||||
.HasIndex(o => o.StoreId);
|
}
|
||||||
builder.Entity<PullPaymentData>()
|
public static IQueryable<PayoutData> GetPayoutInPeriod(this IQueryable<PayoutData> payouts, PullPaymentData pp, DateTimeOffset now)
|
||||||
.HasOne(o => o.StoreData)
|
{
|
||||||
.WithMany(o => o.PullPayments).OnDelete(DeleteBehavior.Cascade);
|
var request = payouts.Where(p => p.PullPaymentDataId == pp.Id);
|
||||||
|
var period = pp.GetPeriod(now);
|
||||||
|
if (period is { } p)
|
||||||
|
{
|
||||||
|
var start = p.Start;
|
||||||
|
if (p.End is DateTimeOffset end)
|
||||||
|
{
|
||||||
|
return request.Where(p => p.Date >= start && p.Date < end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return request.Where(p => p.Date >= start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return request.Where(p => false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetStateString(this PayoutState state)
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case PayoutState.AwaitingApproval:
|
||||||
|
return "Awaiting Approval";
|
||||||
|
case PayoutState.AwaitingPayment:
|
||||||
|
return "Awaiting Payment";
|
||||||
|
case PayoutState.InProgress:
|
||||||
|
return "In Progress";
|
||||||
|
case PayoutState.Completed:
|
||||||
|
return "Completed";
|
||||||
|
case PayoutState.Cancelled:
|
||||||
|
return "Cancelled";
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(state), state, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace BTCPayServer.Data
|
||||||
public PullPaymentData PullPaymentData { get; set; }
|
public PullPaymentData PullPaymentData { get; set; }
|
||||||
public InvoiceData InvoiceData { get; set; }
|
public InvoiceData InvoiceData { get; set; }
|
||||||
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<RefundData>()
|
builder.Entity<RefundData>()
|
||||||
|
|
|
@ -2,14 +2,8 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public class SettingData
|
public class SettingData
|
||||||
{
|
{
|
||||||
public string Id
|
public string Id { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Value
|
public string Value { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ using BTCPayServer.Client.Models;
|
||||||
|
|
||||||
namespace BTCPayServer.Data
|
namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
|
|
||||||
public class StoreData
|
public class StoreData
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
@ -43,6 +42,4 @@ namespace BTCPayServer.Data
|
||||||
public List<PairedSINData> PairedSINs { get; set; }
|
public List<PairedSINData> PairedSINs { get; set; }
|
||||||
public IEnumerable<APIKeyData> APIKeys { get; set; }
|
public IEnumerable<APIKeyData> APIKeys { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace BTCPayServer.Data
|
namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
|
@ -13,6 +9,7 @@ namespace BTCPayServer.Data
|
||||||
public WebhookData Webhook { get; set; }
|
public WebhookData Webhook { get; set; }
|
||||||
public StoreData Store { get; set; }
|
public StoreData Store { get; set; }
|
||||||
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<StoreWebhookData>()
|
builder.Entity<StoreWebhookData>()
|
||||||
|
|
|
@ -12,9 +12,6 @@ namespace BTCPayServer.Data
|
||||||
public string StorageFileName { get; set; }
|
public string StorageFileName { get; set; }
|
||||||
public DateTime Timestamp { get; set; }
|
public DateTime Timestamp { get; set; }
|
||||||
public string ApplicationUserId { get; set; }
|
public string ApplicationUserId { get; set; }
|
||||||
public ApplicationUser ApplicationUser
|
public ApplicationUser ApplicationUser { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,28 +4,13 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public class UserStore
|
public class UserStore
|
||||||
{
|
{
|
||||||
public string ApplicationUserId
|
public string ApplicationUserId { get; set; }
|
||||||
{
|
public ApplicationUser ApplicationUser { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
public string StoreDataId { get; set; }
|
||||||
public ApplicationUser ApplicationUser
|
public StoreData StoreData { get; set; }
|
||||||
{
|
public string Role { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string StoreDataId
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public StoreData StoreData
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public string Role
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace BTCPayServer.Data
|
namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
|
@ -11,6 +9,8 @@ namespace BTCPayServer.Data
|
||||||
public string TransactionId { get; set; }
|
public string TransactionId { get; set; }
|
||||||
public string Labels { get; set; }
|
public string Labels { get; set; }
|
||||||
public byte[] Blob { get; set; }
|
public byte[] Blob { get; set; }
|
||||||
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<WalletTransactionData>()
|
builder.Entity<WalletTransactionData>()
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace BTCPayServer.Data
|
namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
|
@ -10,11 +7,7 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
[MaxLength(25)]
|
[MaxLength(25)]
|
||||||
public string Id
|
public string Id { get; set; }
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
[Required]
|
[Required]
|
||||||
public byte[] Blob { get; set; }
|
public byte[] Blob { get; set; }
|
||||||
public List<WebhookDeliveryData> Deliveries { get; set; }
|
public List<WebhookDeliveryData> Deliveries { get; set; }
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.Text;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace BTCPayServer.Data
|
namespace BTCPayServer.Data
|
||||||
|
@ -18,13 +15,12 @@ namespace BTCPayServer.Data
|
||||||
public WebhookData Webhook { get; set; }
|
public WebhookData Webhook { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public DateTimeOffset Timestamp
|
public DateTimeOffset Timestamp { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public byte[] Blob { get; set; }
|
public byte[] Blob { get; set; }
|
||||||
|
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder)
|
internal static void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<WebhookDeliveryData>()
|
builder.Entity<WebhookDeliveryData>()
|
||||||
|
|
Loading…
Add table
Reference in a new issue