Ejemplo n.º 1
0
    public static JObject GetBlob(this CustodianAccountData custodianAccountData)
    {
        var result = custodianAccountData.Blob == null
            ? new JObject()
            : JObject.Parse(ZipUtils.Unzip(custodianAccountData.Blob));

        return(result);
    }
Ejemplo n.º 2
0
    public static bool SetBlob(this CustodianAccountData custodianAccountData, JObject blob)
    {
        var original = custodianAccountData.GetBlob();

        if (JToken.DeepEquals(original, blob))
        {
            return(false);
        }
        custodianAccountData.Blob = blob is null ? null : ZipUtils.Zip(blob.ToString(Newtonsoft.Json.Formatting.None));
        return(true);
    }
Ejemplo n.º 3
0
        public async Task <CustodianAccountData> CreateOrUpdate(CustodianAccountData entity)
        {
            await using var context = _contextFactory.CreateContext();
            if (string.IsNullOrEmpty(entity.Id))
            {
                entity.Id = Guid.NewGuid().ToString();
                await context.CustodianAccount.AddAsync(entity);
            }
            else
            {
                context.CustodianAccount.Update(entity);
            }

            await context.SaveChangesAsync();

            return(entity);
        }
Ejemplo n.º 4
0
        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);
            CustodianAccountData.OnModelCreating(builder);
            //StoredFile.OnModelCreating(builder);
            InvoiceEventData.OnModelCreating(builder);
            InvoiceSearchData.OnModelCreating(builder);
            InvoiceWebhookDeliveryData.OnModelCreating(builder);
            InvoiceData.OnModelCreating(builder);
            NotificationData.OnModelCreating(builder);
            //OffchainTransactionData.OnModelCreating(builder);
            BTCPayServer.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);
            StoreSettingData.OnModelCreating(builder, Database);
            StoreWebhookData.OnModelCreating(builder);
            //StoreData.OnModelCreating(builder);
            U2FDevice.OnModelCreating(builder);
            Fido2Credential.OnModelCreating(builder);
            BTCPayServer.Data.UserStore.OnModelCreating(builder);
            //WalletData.OnModelCreating(builder);
            WalletTransactionData.OnModelCreating(builder);
            WebhookDeliveryData.OnModelCreating(builder);
            LightningAddressData.OnModelCreating(builder);
            PayoutProcessorData.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());
                    }
                }
            }
        }