Example #1
0
        private InvoiceEntity Clone(InvoiceEntity invoice)
        {
            var temp = new InvoiceData();

            temp.Blob = ToBytes(invoice);
            return(temp.GetBlob(_Networks));
        }
Example #2
0
        public static InvoiceEntity GetBlob(this Data.InvoiceData invoiceData, BTCPayNetworkProvider networks)
        {
            var entity = NBitcoin.JsonConverters.Serializer.ToObject <InvoiceEntity>(ZipUtils.Unzip(invoiceData.Blob), null);

            entity.Networks = networks;
            return(entity);
        }
        public static void RemoveFromTextSearch(ApplicationDbContext context, InvoiceData invoice,
                                                string term)
        {
            var query         = context.InvoiceSearches.AsQueryable();
            var filteredQuery = query.Where(st => st.InvoiceDataId.Equals(invoice.Id) && st.Value.Equals(term));

            context.InvoiceSearches.RemoveRange(filteredQuery);
        }
        public static void AddToTextSearch(ApplicationDbContext context, InvoiceData invoice, params string[] terms)
        {
            var filteredTerms = terms.Where(t => !string.IsNullOrWhiteSpace(t) &&
                                            (invoice.InvoiceSearchData == null || invoice.InvoiceSearchData.All(data => data.Value != t)))
                                .Distinct()
                                .Select(s => new InvoiceSearchData()
            {
                InvoiceDataId = invoice.Id, Value = s.Truncate(512)
            });

            context.AddRange(filteredTerms);
        }
Example #5
0
 public static InvoiceState GetInvoiceState(this InvoiceData invoiceData)
 {
     return(new InvoiceState(invoiceData.Status, invoiceData.ExceptionStatus));
 }
        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            // some of the data models don't have OnModelCreating for now, commenting them

            ApplicationUser.OnModelCreating(builder);
            AddressInvoiceData.OnModelCreating(builder);
            APIKeyData.OnModelCreating(builder);
            AppData.OnModelCreating(builder);
            //StoredFile.OnModelCreating(builder);
            HistoricalAddressInvoiceData.OnModelCreating(builder);
            InvoiceEventData.OnModelCreating(builder);
            InvoiceSearchData.OnModelCreating(builder);
            InvoiceWebhookDeliveryData.OnModelCreating(builder);
            InvoiceData.OnModelCreating(builder);
            NotificationData.OnModelCreating(builder);
            //OffchainTransactionData.OnModelCreating(builder);
            Data.PairedSINData.OnModelCreating(builder);
            PairingCodeData.OnModelCreating(builder);
            //PayjoinLock.OnModelCreating(builder);
            PaymentRequestData.OnModelCreating(builder);
            PaymentData.OnModelCreating(builder);
            PayoutData.OnModelCreating(builder);
            PendingInvoiceData.OnModelCreating(builder);
            //PlannedTransaction.OnModelCreating(builder);
            PullPaymentData.OnModelCreating(builder);
            RefundData.OnModelCreating(builder);
            //SettingData.OnModelCreating(builder);
            StoreWebhookData.OnModelCreating(builder);
            //StoreData.OnModelCreating(builder);
            U2FDevice.OnModelCreating(builder);
            Fido2Credential.OnModelCreating(builder);
            Data.UserStore.OnModelCreating(builder);
            //WalletData.OnModelCreating(builder);
            WalletTransactionData.OnModelCreating(builder);
            WebhookDeliveryData.OnModelCreating(builder);
            //WebhookData.OnModelCreating(builder);


            if (Database.IsSqlite() && !_designTime)
            {
                // SQLite does not have proper support for DateTimeOffset via Entity Framework Core, see the limitations
                // here: https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations#query-limitations
                // To work around this, when the Sqlite database provider is used, all model properties of type DateTimeOffset
                // use the DateTimeOffsetToBinaryConverter
                // Based on: https://github.com/aspnet/EntityFrameworkCore/issues/10784#issuecomment-415769754
                // This only supports millisecond precision, but should be sufficient for most use cases.
                foreach (var entityType in builder.Model.GetEntityTypes())
                {
                    var properties = entityType.ClrType.GetProperties().Where(p => p.PropertyType == typeof(DateTimeOffset));
                    foreach (var property in properties)
                    {
                        builder
                        .Entity(entityType.Name)
                        .Property(property.Name)
                        .HasConversion(new Microsoft.EntityFrameworkCore.Storage.ValueConversion.DateTimeOffsetToBinaryConverter());
                    }
                }
            }
        }