btcpayserver/BTCPayServer.Data/Data/InvoiceData.cs

53 lines
1.9 KiB
C#
Raw Normal View History

2020-05-07 12:50:07 +02:00
using System;
2017-09-13 08:47:34 +02:00
using System.Collections.Generic;
2020-06-24 10:51:00 +02:00
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
2017-09-13 08:47:34 +02:00
namespace BTCPayServer.Data
{
public class InvoiceData : IHasBlobUntyped
{
public string Id { get; set; }
2017-09-13 08:47:34 +02:00
public string StoreDataId { get; set; }
public StoreData StoreData { get; set; }
2017-09-13 08:47:34 +02:00
public DateTimeOffset Created { get; set; }
public List<PaymentData> Payments { get; set; }
public List<InvoiceEventData> Events { get; set; }
2018-01-14 13:48:23 +01:00
[Obsolete("Use Blob2 instead")]
public byte[] Blob { get; set; }
public string Blob2 { 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; }
2020-05-07 12:50:07 +02:00
public bool Archived { get; set; }
2018-07-19 12:31:17 +02:00
public List<PendingInvoiceData> PendingInvoices { get; set; }
public List<InvoiceSearchData> InvoiceSearchData { get; set; }
2020-06-24 10:51:00 +02:00
public List<RefundData> Refunds { get; set; }
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
2020-06-24 10:51:00 +02:00
{
builder.Entity<InvoiceData>()
.HasOne(o => o.StoreData)
.WithMany(a => a.Invoices).OnDelete(DeleteBehavior.Cascade);
builder.Entity<InvoiceData>().HasIndex(o => o.StoreDataId);
builder.Entity<InvoiceData>().HasIndex(o => o.OrderId);
builder.Entity<InvoiceData>().HasIndex(o => o.Created);
if (databaseFacade.IsNpgsql())
{
builder.Entity<InvoiceData>()
.Property(o => o.Blob2)
.HasColumnType("JSONB");
}
2020-06-24 10:51:00 +02:00
}
}
2017-09-13 08:47:34 +02:00
}