diff --git a/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj b/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj index 24011917a..5c1226f22 100644 --- a/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj +++ b/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj @@ -30,4 +30,10 @@ + + + + + + diff --git a/BTCPayServer.Abstractions/Constants/AuthenticationSchemes.cs b/BTCPayServer.Abstractions/Constants/AuthenticationSchemes.cs index 652d06997..007acc6a8 100644 --- a/BTCPayServer.Abstractions/Constants/AuthenticationSchemes.cs +++ b/BTCPayServer.Abstractions/Constants/AuthenticationSchemes.cs @@ -1,4 +1,4 @@ -namespace BTCPayServer.Security +namespace BTCPayServer.Abstractions.Constants { public class AuthenticationSchemes { diff --git a/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs b/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs new file mode 100644 index 000000000..0997c9120 --- /dev/null +++ b/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs @@ -0,0 +1,108 @@ +using System; +using BTCPayServer.Abstractions.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Migrations.Operations; + +namespace BTCPayServer.Abstractions.Contracts +{ + public abstract class BaseDbContextFactory where T: DbContext + { + private readonly DatabaseOptions _options; + private readonly string _schemaPrefix; + + public BaseDbContextFactory(DatabaseOptions options, string schemaPrefix) + { + _options = options; + _schemaPrefix = schemaPrefix; + } + + public abstract T CreateContext(); + + class CustomNpgsqlMigrationsSqlGenerator : NpgsqlMigrationsSqlGenerator + { + public CustomNpgsqlMigrationsSqlGenerator(MigrationsSqlGeneratorDependencies dependencies, IMigrationsAnnotationProvider annotations, Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.INpgsqlOptions opts) : base(dependencies, annotations, opts) + { + } + + protected override void Generate(NpgsqlCreateDatabaseOperation operation, IModel model, MigrationCommandListBuilder builder) + { + builder + .Append("CREATE DATABASE ") + .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name)); + + // POSTGRES gotcha: Indexed Text column (even if PK) are not used if we are not using C locale + builder + .Append(" TEMPLATE ") + .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("template0")); + + builder + .Append(" LC_CTYPE ") + .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("C")); + + builder + .Append(" LC_COLLATE ") + .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("C")); + + builder + .Append(" ENCODING ") + .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("UTF8")); + + if (operation.Tablespace != null) + { + builder + .Append(" TABLESPACE ") + .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Tablespace)); + } + + builder.AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator); + + EndStatement(builder, suppressTransaction: true); + } + } + + public void ConfigureBuilder(DbContextOptionsBuilder builder) + { + switch (_options.DatabaseType) + { + case DatabaseType.Sqlite: + builder.UseSqlite(_options.ConnectionString, o => + { + if (!string.IsNullOrEmpty(_schemaPrefix)) + { + o.MigrationsHistoryTable(_schemaPrefix); + } + }); + break; + case DatabaseType.Postgres: + builder + .UseNpgsql(_options.ConnectionString, o => + { + o.EnableRetryOnFailure(10); + if (!string.IsNullOrEmpty(_schemaPrefix)) + { + o.MigrationsHistoryTable(_schemaPrefix); + } + }) + .ReplaceService(); + break; + case DatabaseType.MySQL: + builder.UseMySql(_options.ConnectionString, o => + { + o.EnableRetryOnFailure(10); + + if (!string.IsNullOrEmpty(_schemaPrefix)) + { + o.MigrationsHistoryTable(_schemaPrefix); + } + }); + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + } +} diff --git a/BTCPayServer.Abstractions/Contracts/IBTCPayServerPlugin.cs b/BTCPayServer.Abstractions/Contracts/IBTCPayServerPlugin.cs index a82103ac9..b59b9cd18 100644 --- a/BTCPayServer.Abstractions/Contracts/IBTCPayServerPlugin.cs +++ b/BTCPayServer.Abstractions/Contracts/IBTCPayServerPlugin.cs @@ -4,7 +4,7 @@ using BTCPayServer.Abstractions.Converters; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -namespace BTCPayServer.Contracts +namespace BTCPayServer.Abstractions.Contracts { public interface IBTCPayServerPlugin { diff --git a/BTCPayServer.Abstractions/Contracts/INotificationHandler.cs b/BTCPayServer.Abstractions/Contracts/INotificationHandler.cs index 999d54085..b756feb9b 100644 --- a/BTCPayServer.Abstractions/Contracts/INotificationHandler.cs +++ b/BTCPayServer.Abstractions/Contracts/INotificationHandler.cs @@ -1,6 +1,6 @@ using System; -namespace BTCPayServer.Contracts +namespace BTCPayServer.Abstractions.Contracts { public abstract class BaseNotification { diff --git a/BTCPayServer.Abstractions/Contracts/IPluginHookAction.cs b/BTCPayServer.Abstractions/Contracts/IPluginHookAction.cs index 55aa4bdc1..2307b30aa 100644 --- a/BTCPayServer.Abstractions/Contracts/IPluginHookAction.cs +++ b/BTCPayServer.Abstractions/Contracts/IPluginHookAction.cs @@ -1,10 +1,10 @@ using System.Threading.Tasks; -namespace BTCPayServer.Contracts +namespace BTCPayServer.Abstractions.Contracts { public interface IPluginHookAction { public string Hook { get; } Task Execute(object args); } -} \ No newline at end of file +} diff --git a/BTCPayServer.Abstractions/Contracts/IPluginHookFilter.cs b/BTCPayServer.Abstractions/Contracts/IPluginHookFilter.cs index 54a16f5e6..6e319783e 100644 --- a/BTCPayServer.Abstractions/Contracts/IPluginHookFilter.cs +++ b/BTCPayServer.Abstractions/Contracts/IPluginHookFilter.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace BTCPayServer.Contracts +namespace BTCPayServer.Abstractions.Contracts { public interface IPluginHookFilter { @@ -8,4 +8,4 @@ namespace BTCPayServer.Contracts Task Execute(object args); } -} \ No newline at end of file +} diff --git a/BTCPayServer.Abstractions/Contracts/IPluginHookService.cs b/BTCPayServer.Abstractions/Contracts/IPluginHookService.cs index b1120ad43..2c440b0de 100644 --- a/BTCPayServer.Abstractions/Contracts/IPluginHookService.cs +++ b/BTCPayServer.Abstractions/Contracts/IPluginHookService.cs @@ -1,10 +1,10 @@ using System.Threading.Tasks; -namespace BTCPayServer.Contracts +namespace BTCPayServer.Abstractions.Contracts { public interface IPluginHookService { Task ApplyAction(string hook, object args); Task ApplyFilter(string hook, object args); } -} \ No newline at end of file +} diff --git a/BTCPayServer.Abstractions/Contracts/ISettingsRepository.cs b/BTCPayServer.Abstractions/Contracts/ISettingsRepository.cs index add724d6d..182443a3b 100644 --- a/BTCPayServer.Abstractions/Contracts/ISettingsRepository.cs +++ b/BTCPayServer.Abstractions/Contracts/ISettingsRepository.cs @@ -1,7 +1,7 @@ using System.Threading; using System.Threading.Tasks; -namespace BTCPayServer.Services +namespace BTCPayServer.Abstractions.Contracts { public interface ISettingsRepository { diff --git a/BTCPayServer.Abstractions/Contracts/IStartupTask.cs b/BTCPayServer.Abstractions/Contracts/IStartupTask.cs index 69ec7b505..bfa873bd2 100644 --- a/BTCPayServer.Abstractions/Contracts/IStartupTask.cs +++ b/BTCPayServer.Abstractions/Contracts/IStartupTask.cs @@ -1,7 +1,7 @@ using System.Threading; using System.Threading.Tasks; -namespace BTCPayServer.Hosting +namespace BTCPayServer.Abstractions.Contracts { public interface IStartupTask { diff --git a/BTCPayServer.Abstractions/Contracts/ISyncSummaryProvider.cs b/BTCPayServer.Abstractions/Contracts/ISyncSummaryProvider.cs index 9843da32e..5f1171f32 100644 --- a/BTCPayServer.Abstractions/Contracts/ISyncSummaryProvider.cs +++ b/BTCPayServer.Abstractions/Contracts/ISyncSummaryProvider.cs @@ -1,4 +1,4 @@ -namespace BTCPayServer.Contracts +namespace BTCPayServer.Abstractions.Contracts { public interface ISyncSummaryProvider { diff --git a/BTCPayServer.Abstractions/Contracts/IUIExtension.cs b/BTCPayServer.Abstractions/Contracts/IUIExtension.cs index b5b2cf5f1..1539d8d53 100644 --- a/BTCPayServer.Abstractions/Contracts/IUIExtension.cs +++ b/BTCPayServer.Abstractions/Contracts/IUIExtension.cs @@ -1,4 +1,4 @@ -namespace BTCPayServer.Contracts +namespace BTCPayServer.Abstractions.Contracts { public interface IUIExtension { @@ -6,4 +6,4 @@ namespace BTCPayServer.Contracts string Location { get; } } -} \ No newline at end of file +} diff --git a/BTCPayServer.Abstractions/Extensions/Extensions.cs b/BTCPayServer.Abstractions/Extensions/Extensions.cs index 98c3f5973..d8c762fb1 100644 --- a/BTCPayServer.Abstractions/Extensions/Extensions.cs +++ b/BTCPayServer.Abstractions/Extensions/Extensions.cs @@ -1,8 +1,8 @@ using System.Text.Json; -using BTCPayServer.Models; +using BTCPayServer.Abstractions.Models; using Microsoft.AspNetCore.Mvc.ViewFeatures; -namespace BTCPayServer +namespace BTCPayServer.Abstractions.Extensions { public static class SetStatusMessageModelExtensions { diff --git a/BTCPayServer.Abstractions/Extensions/ServiceCollectionExtensions.cs b/BTCPayServer.Abstractions/Extensions/ServiceCollectionExtensions.cs index 3a21f649f..5b505b766 100644 --- a/BTCPayServer.Abstractions/Extensions/ServiceCollectionExtensions.cs +++ b/BTCPayServer.Abstractions/Extensions/ServiceCollectionExtensions.cs @@ -1,6 +1,7 @@ -using BTCPayServer.Hosting; +using BTCPayServer.Abstractions.Contracts; +using Microsoft.Extensions.DependencyInjection; -namespace Microsoft.Extensions.DependencyInjection +namespace BTCPayServer.Abstractions.Extensions { public static class ServiceCollectionExtensions { diff --git a/BTCPayServer.Abstractions/Models/BaseBTCPayServerPlugin.cs b/BTCPayServer.Abstractions/Models/BaseBTCPayServerPlugin.cs index 29a86f3d8..d5c42b39c 100644 --- a/BTCPayServer.Abstractions/Models/BaseBTCPayServerPlugin.cs +++ b/BTCPayServer.Abstractions/Models/BaseBTCPayServerPlugin.cs @@ -1,10 +1,10 @@ using System; using System.Reflection; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -namespace BTCPayServer.Models +namespace BTCPayServer.Abstractions.Models { public abstract class BaseBTCPayServerPlugin : IBTCPayServerPlugin { diff --git a/BTCPayServer.Abstractions/Models/DatabaseOptions.cs b/BTCPayServer.Abstractions/Models/DatabaseOptions.cs new file mode 100644 index 000000000..2c518aaa9 --- /dev/null +++ b/BTCPayServer.Abstractions/Models/DatabaseOptions.cs @@ -0,0 +1,14 @@ +namespace BTCPayServer.Abstractions.Models +{ + public class DatabaseOptions + { + public DatabaseOptions(DatabaseType type, string connString) + { + DatabaseType = type; + ConnectionString = connString; + } + + public DatabaseType DatabaseType { get; set; } + public string ConnectionString { get; set; } + } +} diff --git a/BTCPayServer.Abstractions/Models/DatabaseType.cs b/BTCPayServer.Abstractions/Models/DatabaseType.cs new file mode 100644 index 000000000..09347b2e1 --- /dev/null +++ b/BTCPayServer.Abstractions/Models/DatabaseType.cs @@ -0,0 +1,9 @@ +namespace BTCPayServer.Abstractions.Models +{ + public enum DatabaseType + { + Sqlite, + Postgres, + MySQL, + } +} diff --git a/BTCPayServer.Abstractions/Models/StatusMessageModel.cs b/BTCPayServer.Abstractions/Models/StatusMessageModel.cs index 4b4f68543..2543cd400 100644 --- a/BTCPayServer.Abstractions/Models/StatusMessageModel.cs +++ b/BTCPayServer.Abstractions/Models/StatusMessageModel.cs @@ -1,6 +1,6 @@ using System; -namespace BTCPayServer.Models +namespace BTCPayServer.Abstractions.Models { public class StatusMessageModel { diff --git a/BTCPayServer.Abstractions/Contracts/PluginAction.cs b/BTCPayServer.Abstractions/Services/PluginAction.cs similarity index 77% rename from BTCPayServer.Abstractions/Contracts/PluginAction.cs rename to BTCPayServer.Abstractions/Services/PluginAction.cs index 9d989f888..35aaff142 100644 --- a/BTCPayServer.Abstractions/Contracts/PluginAction.cs +++ b/BTCPayServer.Abstractions/Services/PluginAction.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; +using BTCPayServer.Abstractions.Contracts; -namespace BTCPayServer.Contracts +namespace BTCPayServer.Abstractions.Services { public abstract class PluginAction:IPluginHookAction { @@ -12,4 +13,4 @@ namespace BTCPayServer.Contracts public abstract Task Execute(T arg); } -} \ No newline at end of file +} diff --git a/BTCPayServer.Abstractions/Contracts/PluginHookFilter.cs b/BTCPayServer.Abstractions/Services/PluginHookFilter.cs similarity index 80% rename from BTCPayServer.Abstractions/Contracts/PluginHookFilter.cs rename to BTCPayServer.Abstractions/Services/PluginHookFilter.cs index 24e186ab5..02751b980 100644 --- a/BTCPayServer.Abstractions/Contracts/PluginHookFilter.cs +++ b/BTCPayServer.Abstractions/Services/PluginHookFilter.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; +using BTCPayServer.Abstractions.Contracts; -namespace BTCPayServer.Contracts +namespace BTCPayServer.Abstractions.Services { public abstract class PluginHookFilter:IPluginHookFilter { @@ -12,4 +13,4 @@ namespace BTCPayServer.Contracts public abstract Task Execute(T arg); } -} \ No newline at end of file +} diff --git a/BTCPayServer.Abstractions/Contracts/UIExtension.cs b/BTCPayServer.Abstractions/Services/UIExtension.cs similarity index 76% rename from BTCPayServer.Abstractions/Contracts/UIExtension.cs rename to BTCPayServer.Abstractions/Services/UIExtension.cs index 62dd41835..512f698bb 100644 --- a/BTCPayServer.Abstractions/Contracts/UIExtension.cs +++ b/BTCPayServer.Abstractions/Services/UIExtension.cs @@ -1,4 +1,6 @@ -namespace BTCPayServer.Contracts +using BTCPayServer.Abstractions.Contracts; + +namespace BTCPayServer.Abstractions.Services { public class UIExtension: IUIExtension { diff --git a/BTCPayServer.Data/BTCPayServer.Data.csproj b/BTCPayServer.Data/BTCPayServer.Data.csproj index f44139247..479d9db9d 100644 --- a/BTCPayServer.Data/BTCPayServer.Data.csproj +++ b/BTCPayServer.Data/BTCPayServer.Data.csproj @@ -7,12 +7,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + diff --git a/BTCPayServer.Data/Data/ApplicationDbContextFactory.cs b/BTCPayServer.Data/Data/ApplicationDbContextFactory.cs index cdbcfe3ef..9aefd3e64 100644 --- a/BTCPayServer.Data/Data/ApplicationDbContextFactory.cs +++ b/BTCPayServer.Data/Data/ApplicationDbContextFactory.cs @@ -1,96 +1,20 @@ -using System; +using BTCPayServer.Abstractions.Contracts; +using BTCPayServer.Abstractions.Models; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Migrations.Operations; namespace BTCPayServer.Data { - public enum DatabaseType + public class ApplicationDbContextFactory : BaseDbContextFactory { - Sqlite, - Postgres, - MySQL, - } - public class ApplicationDbContextFactory - { - readonly string _ConnectionString; - readonly DatabaseType _Type; - public ApplicationDbContextFactory(DatabaseType type, string connectionString) + public ApplicationDbContextFactory(DatabaseOptions options) : base(options, "") { - _ConnectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString)); - _Type = type; } - - public DatabaseType Type - { - get - { - return _Type; - } - } - - public ApplicationDbContext CreateContext() + public override ApplicationDbContext CreateContext() { var builder = new DbContextOptionsBuilder(); ConfigureBuilder(builder); return new ApplicationDbContext(builder.Options); } - - class CustomNpgsqlMigrationsSqlGenerator : NpgsqlMigrationsSqlGenerator - { - public CustomNpgsqlMigrationsSqlGenerator(MigrationsSqlGeneratorDependencies dependencies, IMigrationsAnnotationProvider annotations, Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.INpgsqlOptions opts) : base(dependencies, annotations, opts) - { - } - - protected override void Generate(NpgsqlCreateDatabaseOperation operation, IModel model, MigrationCommandListBuilder builder) - { - builder - .Append("CREATE DATABASE ") - .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name)); - - // POSTGRES gotcha: Indexed Text column (even if PK) are not used if we are not using C locale - builder - .Append(" TEMPLATE ") - .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("template0")); - - builder - .Append(" LC_CTYPE ") - .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("C")); - - builder - .Append(" LC_COLLATE ") - .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("C")); - - builder - .Append(" ENCODING ") - .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("UTF8")); - - if (operation.Tablespace != null) - { - builder - .Append(" TABLESPACE ") - .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Tablespace)); - } - - builder.AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator); - - EndStatement(builder, suppressTransaction: true); - } - } - - public void ConfigureBuilder(DbContextOptionsBuilder builder) - { - if (_Type == DatabaseType.Sqlite) - builder.UseSqlite(_ConnectionString, o => o.MigrationsAssembly("BTCPayServer.Data")); - else if (_Type == DatabaseType.Postgres) - builder - .UseNpgsql(_ConnectionString, o => o.MigrationsAssembly("BTCPayServer.Data").EnableRetryOnFailure(10)) - .ReplaceService(); - else if (_Type == DatabaseType.MySQL) - builder.UseMySql(_ConnectionString, o => o.MigrationsAssembly("BTCPayServer.Data").EnableRetryOnFailure(10)); - } } } diff --git a/BTCPayServer.PluginPacker/Program.cs b/BTCPayServer.PluginPacker/Program.cs index 3d56af9b4..d09f9e67b 100644 --- a/BTCPayServer.PluginPacker/Program.cs +++ b/BTCPayServer.PluginPacker/Program.cs @@ -4,7 +4,7 @@ using System.IO.Compression; using System.Linq; using System.Reflection; using System.Text.Json; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; namespace BTCPayServer.PluginPacker { diff --git a/BTCPayServer.Plugins.Test/BTCPayServer.Plugins.Test.csproj b/BTCPayServer.Plugins.Test/BTCPayServer.Plugins.Test.csproj index 3a084657c..aa263c9a7 100644 --- a/BTCPayServer.Plugins.Test/BTCPayServer.Plugins.Test.csproj +++ b/BTCPayServer.Plugins.Test/BTCPayServer.Plugins.Test.csproj @@ -12,4 +12,8 @@ + + + + diff --git a/BTCPayServer.Plugins.Test/Controllers/TestExtensionController.cs b/BTCPayServer.Plugins.Test/Controllers/TestExtensionController.cs new file mode 100644 index 000000000..da62a1439 --- /dev/null +++ b/BTCPayServer.Plugins.Test/Controllers/TestExtensionController.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using BTCPayServer.Plugins.Test.Data; +using BTCPayServer.Plugins.Test.Services; +using Microsoft.AspNetCore.Mvc; + +namespace BTCPayServer.Plugins.Test +{ + [Route("extensions/test")] + public class TestExtensionController : Controller + { + private readonly TestPluginService _testPluginService; + + public TestExtensionController(TestPluginService testPluginService) + { + _testPluginService = testPluginService; + } + + // GET + public async Task Index() + { + return View(new TestPluginPageViewModel() + { + Data = await _testPluginService.Get() + }); + } + + + } + + public class TestPluginPageViewModel + { + public List Data { get; set; } + } +} diff --git a/BTCPayServer.Plugins.Test/Data/TestPluginData.cs b/BTCPayServer.Plugins.Test/Data/TestPluginData.cs new file mode 100644 index 000000000..f60515d95 --- /dev/null +++ b/BTCPayServer.Plugins.Test/Data/TestPluginData.cs @@ -0,0 +1,14 @@ +using System; +using System.ComponentModel.DataAnnotations.Schema; + +namespace BTCPayServer.Plugins.Test.Data +{ + public class TestPluginData + { + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public string Id { get; set; } + public DateTimeOffset Timestamp { get; set; } + + + } +} diff --git a/BTCPayServer.Plugins.Test/Data/TestPluginDbContext.cs b/BTCPayServer.Plugins.Test/Data/TestPluginDbContext.cs new file mode 100644 index 000000000..a8e51b1cc --- /dev/null +++ b/BTCPayServer.Plugins.Test/Data/TestPluginDbContext.cs @@ -0,0 +1,46 @@ +using System; +using System.Linq; +using BTCPayServer.Plugins.Test.Data; +using Microsoft.EntityFrameworkCore; + +namespace BTCPayServer.Plugins.Test +{ + public class TestPluginDbContext : DbContext + { + private readonly bool _designTime; + + public DbSet TestPluginRecords { get; set; } + + public TestPluginDbContext(DbContextOptions options, bool designTime = false) + : base(options) + { + _designTime = designTime; + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + modelBuilder.HasDefaultSchema("BTCPayServer.Plugins.Test"); + 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 modelBuilder.Model.GetEntityTypes()) + { + var properties = entityType.ClrType.GetProperties().Where(p => p.PropertyType == typeof(DateTimeOffset)); + foreach (var property in properties) + { + modelBuilder + .Entity(entityType.Name) + .Property(property.Name) + .HasConversion(new Microsoft.EntityFrameworkCore.Storage.ValueConversion.DateTimeOffsetToBinaryConverter()); + } + } + } + } + } +} diff --git a/BTCPayServer.Plugins.Test/Migrations/20201117154419_Init.cs b/BTCPayServer.Plugins.Test/Migrations/20201117154419_Init.cs new file mode 100644 index 000000000..84737650e --- /dev/null +++ b/BTCPayServer.Plugins.Test/Migrations/20201117154419_Init.cs @@ -0,0 +1,37 @@ +using System; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace BTCPayServer.Plugins.Test.Migrations +{ + [DbContext(typeof(TestPluginDbContext))] + [Migration("20201117154419_Init")] + public partial class Init : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "BTCPayServer.Plugins.Test"); + + migrationBuilder.CreateTable( + name: "TestPluginRecords", + schema: "BTCPayServer.Plugins.Test", + columns: table => new + { + Id = table.Column(nullable: false), + Timestamp = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TestPluginRecords", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TestPluginRecords", + schema: "BTCPayServer.Plugins.Test"); + } + } +} diff --git a/BTCPayServer.Plugins.Test/Migrations/TestPluginDbContextModelSnapshot.cs b/BTCPayServer.Plugins.Test/Migrations/TestPluginDbContextModelSnapshot.cs new file mode 100644 index 000000000..d96cd7d03 --- /dev/null +++ b/BTCPayServer.Plugins.Test/Migrations/TestPluginDbContextModelSnapshot.cs @@ -0,0 +1,36 @@ +// +using System; +using BTCPayServer.Plugins.Test; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace BTCPayServer.Plugins.Test.Migrations +{ + [DbContext(typeof(TestPluginDbContext))] + partial class TestPluginDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("BTCPayServer.Plugins.Test") + .HasAnnotation("ProductVersion", "3.1.10"); + + modelBuilder.Entity("BTCPayServer.Plugins.Test.Data.TestPluginData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("TestPluginRecords"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BTCPayServer.Plugins.Test/ApplicationPartsLogger.cs b/BTCPayServer.Plugins.Test/Services/ApplicationPartsLogger.cs similarity index 100% rename from BTCPayServer.Plugins.Test/ApplicationPartsLogger.cs rename to BTCPayServer.Plugins.Test/Services/ApplicationPartsLogger.cs diff --git a/BTCPayServer.Plugins.Test/Services/TestPluginDbContextFactory.cs b/BTCPayServer.Plugins.Test/Services/TestPluginDbContextFactory.cs new file mode 100644 index 000000000..778faa6f3 --- /dev/null +++ b/BTCPayServer.Plugins.Test/Services/TestPluginDbContextFactory.cs @@ -0,0 +1,38 @@ +using System.Reflection; +using BTCPayServer.Abstractions.Contracts; +using BTCPayServer.Abstractions.Models; +using BTCPayServer.Plugins.Test.Migrations; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; + +namespace BTCPayServer.Plugins.Test +{ + + public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory + { + public TestPluginDbContext CreateDbContext(string[] args) + { + + var builder = new DbContextOptionsBuilder(); + + builder.UseSqlite("Data Source=temp.db"); + + return new TestPluginDbContext(builder.Options, true); + } + } + + public class TestPluginDbContextFactory : BaseDbContextFactory + { + public TestPluginDbContextFactory(DatabaseOptions options) : base(options, "BTCPayServer.Plugins.Test") + { + } + + public override TestPluginDbContext CreateContext() + { + var builder = new DbContextOptionsBuilder(); + ConfigureBuilder(builder); + return new TestPluginDbContext(builder.Options); + + } + } +} diff --git a/BTCPayServer.Plugins.Test/Services/TestPluginService.cs b/BTCPayServer.Plugins.Test/Services/TestPluginService.cs new file mode 100644 index 000000000..f162ab826 --- /dev/null +++ b/BTCPayServer.Plugins.Test/Services/TestPluginService.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using BTCPayServer.Plugins.Test.Data; +using Microsoft.EntityFrameworkCore; + +namespace BTCPayServer.Plugins.Test.Services +{ + public class TestPluginService + { + private readonly TestPluginDbContextFactory _testPluginDbContextFactory; + + public TestPluginService(TestPluginDbContextFactory testPluginDbContextFactory) + { + _testPluginDbContextFactory = testPluginDbContextFactory; + } + + public async Task AddTestDataRecord() + { + await using var context = _testPluginDbContextFactory.CreateContext(); + + await context.TestPluginRecords.AddAsync(new TestPluginData() {Timestamp = DateTimeOffset.UtcNow}); + } + + + public async Task> Get() + { + await using var context = _testPluginDbContextFactory.CreateContext(); + + return await context.TestPluginRecords.ToListAsync(); + } + } +} diff --git a/BTCPayServer.Plugins.Test/TestExtension.cs b/BTCPayServer.Plugins.Test/TestExtension.cs index f28fcf402..2d6fe164d 100644 --- a/BTCPayServer.Plugins.Test/TestExtension.cs +++ b/BTCPayServer.Plugins.Test/TestExtension.cs @@ -1,5 +1,10 @@ -using BTCPayServer.Contracts; -using BTCPayServer.Models; +using System; +using BTCPayServer.Abstractions.Contracts; +using BTCPayServer.Abstractions.Models; +using BTCPayServer.Abstractions.Services; +using BTCPayServer.Plugins.Test.Services; +using Microsoft.AspNetCore.Builder; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; namespace BTCPayServer.Plugins.Test @@ -14,6 +19,21 @@ namespace BTCPayServer.Plugins.Test { services.AddSingleton(new UIExtension("TestExtensionNavExtension", "header-nav")); services.AddHostedService(); + services.AddSingleton(); + services.AddSingleton(); + services.AddDbContext((provider, o) => + { + var factory = provider.GetRequiredService(); + factory.ConfigureBuilder(o); + }); + } + + public override void Execute(IApplicationBuilder applicationBuilder, IServiceProvider applicationBuilderApplicationServices) + { + base.Execute(applicationBuilder, applicationBuilderApplicationServices); + applicationBuilderApplicationServices.GetService().CreateContext().Database.Migrate(); + applicationBuilderApplicationServices.GetService().AddTestDataRecord().GetAwaiter().GetResult(); + } } } diff --git a/BTCPayServer.Plugins.Test/TestExtensionController.cs b/BTCPayServer.Plugins.Test/TestExtensionController.cs deleted file mode 100644 index a5bfcc166..000000000 --- a/BTCPayServer.Plugins.Test/TestExtensionController.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace BTCPayServer.Plugins.Test -{ - [Route("extensions/test")] - public class TestExtensionController : Controller - { - // GET - public IActionResult Index() - { - return View(); - } - - - } -} diff --git a/BTCPayServer.Plugins.Test/Views/TestExtension/Index.cshtml b/BTCPayServer.Plugins.Test/Views/TestExtension/Index.cshtml index f87d76718..3c761d54a 100644 --- a/BTCPayServer.Plugins.Test/Views/TestExtension/Index.cshtml +++ b/BTCPayServer.Plugins.Test/Views/TestExtension/Index.cshtml @@ -1,3 +1,4 @@ +@model BTCPayServer.Plugins.Test.TestPluginPageViewModel

Challenge Completed!!

@@ -5,5 +6,16 @@ + +
+

Persisted Data

+

The following is data persisted to the configured database but in an isolated DbContext. Every time you start BTCPayw with this plugin enabled, a timestamp is logged.

+
    > + @foreach (var item in Model.Data) + { +
  • @item.Id at @item.Timestamp.ToString("F")
  • + } +
+
diff --git a/BTCPayServer.Tests/BTCPayServerTester.cs b/BTCPayServer.Tests/BTCPayServerTester.cs index c0ea88d9a..2ceeca809 100644 --- a/BTCPayServer.Tests/BTCPayServerTester.cs +++ b/BTCPayServer.Tests/BTCPayServerTester.cs @@ -26,7 +26,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using NBitcoin; using NBXplorer; -using AuthenticationSchemes = BTCPayServer.Security.AuthenticationSchemes; +using AuthenticationSchemes = BTCPayServer.Abstractions.Constants.AuthenticationSchemes; namespace BTCPayServer.Tests { diff --git a/BTCPayServer.Tests/PayJoinTests.cs b/BTCPayServer.Tests/PayJoinTests.cs index 41825f703..97040cdc0 100644 --- a/BTCPayServer.Tests/PayJoinTests.cs +++ b/BTCPayServer.Tests/PayJoinTests.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client.Models; using BTCPayServer.Controllers; using BTCPayServer.Data; diff --git a/BTCPayServer.Tests/SeleniumTester.cs b/BTCPayServer.Tests/SeleniumTester.cs index 69a943834..d9f87f405 100644 --- a/BTCPayServer.Tests/SeleniumTester.cs +++ b/BTCPayServer.Tests/SeleniumTester.cs @@ -6,6 +6,7 @@ using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using BTCPayServer; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Lightning; using BTCPayServer.Lightning.CLightning; using BTCPayServer.Models; diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index ac4881a86..3f22bc605 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -5,6 +5,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.Models; diff --git a/BTCPayServer.Tests/StorageTests.cs b/BTCPayServer.Tests/StorageTests.cs index e72b1c460..ba04a922c 100644 --- a/BTCPayServer.Tests/StorageTests.cs +++ b/BTCPayServer.Tests/StorageTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Controllers; using BTCPayServer.Models; using BTCPayServer.Models.ServerViewModels; diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 28a5eca18..58ccf93a0 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -11,6 +11,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Configuration; diff --git a/BTCPayServer/Components/NotificationsDropdown/NotificationSummaryViewModel.cs b/BTCPayServer/Components/NotificationsDropdown/NotificationSummaryViewModel.cs index 8f135903d..e692f313f 100644 --- a/BTCPayServer/Components/NotificationsDropdown/NotificationSummaryViewModel.cs +++ b/BTCPayServer/Components/NotificationsDropdown/NotificationSummaryViewModel.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Models.NotificationViewModels; namespace BTCPayServer.Components.NotificationsDropdown diff --git a/BTCPayServer/Components/UIExtensionPoint/UIExtensionPoint.cs b/BTCPayServer/Components/UIExtensionPoint/UIExtensionPoint.cs index 9d4fedade..75fc2a9e8 100644 --- a/BTCPayServer/Components/UIExtensionPoint/UIExtensionPoint.cs +++ b/BTCPayServer/Components/UIExtensionPoint/UIExtensionPoint.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; using Microsoft.AspNetCore.Mvc; namespace BTCPayServer.Components.UIExtensionPoint diff --git a/BTCPayServer/Controllers/AccessTokenController.cs b/BTCPayServer/Controllers/AccessTokenController.cs index 8259333b8..844c7a998 100644 --- a/BTCPayServer/Controllers/AccessTokenController.cs +++ b/BTCPayServer/Controllers/AccessTokenController.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Filters; using BTCPayServer.Models; using BTCPayServer.Security.Bitpay; @@ -9,7 +10,7 @@ using Microsoft.AspNetCore.Mvc; namespace BTCPayServer.Controllers { - [Authorize(AuthenticationSchemes = Security.AuthenticationSchemes.Bitpay)] + [Authorize(AuthenticationSchemes = AuthenticationSchemes.Bitpay)] [BitpayAPIConstraint()] public class AccessTokenController : Controller { diff --git a/BTCPayServer/Controllers/AccountController.cs b/BTCPayServer/Controllers/AccountController.cs index 3c2ac509f..0e74e30e3 100644 --- a/BTCPayServer/Controllers/AccountController.cs +++ b/BTCPayServer/Controllers/AccountController.cs @@ -1,6 +1,9 @@ using System; using System.Globalization; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Data; using BTCPayServer.Events; using BTCPayServer.Logging; diff --git a/BTCPayServer/Controllers/AppsController.cs b/BTCPayServer/Controllers/AppsController.cs index 3a788e384..71d7ec45a 100644 --- a/BTCPayServer/Controllers/AppsController.cs +++ b/BTCPayServer/Controllers/AppsController.cs @@ -1,6 +1,9 @@ using System; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Data; using BTCPayServer.Models; using BTCPayServer.Models.AppViewModels; diff --git a/BTCPayServer/Controllers/AppsPublicController.cs b/BTCPayServer/Controllers/AppsPublicController.cs index 2366c00f0..80e572523 100644 --- a/BTCPayServer/Controllers/AppsPublicController.cs +++ b/BTCPayServer/Controllers/AppsPublicController.cs @@ -4,6 +4,8 @@ using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Configuration; using BTCPayServer.Data; using BTCPayServer.Filters; diff --git a/BTCPayServer/Controllers/GreenField/ApiKeysController.cs b/BTCPayServer/Controllers/GreenField/ApiKeysController.cs index 6b95460d4..ca6549212 100644 --- a/BTCPayServer/Controllers/GreenField/ApiKeysController.cs +++ b/BTCPayServer/Controllers/GreenField/ApiKeysController.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; diff --git a/BTCPayServer/Controllers/GreenField/InvoiceController.cs b/BTCPayServer/Controllers/GreenField/InvoiceController.cs index c80b4fe97..d05e2075d 100644 --- a/BTCPayServer/Controllers/GreenField/InvoiceController.cs +++ b/BTCPayServer/Controllers/GreenField/InvoiceController.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Models.InvoicingModels; diff --git a/BTCPayServer/Controllers/GreenField/LightningNodeApiController.Internal.cs b/BTCPayServer/Controllers/GreenField/LightningNodeApiController.Internal.cs index ceb006127..7d86f75ed 100644 --- a/BTCPayServer/Controllers/GreenField/LightningNodeApiController.Internal.cs +++ b/BTCPayServer/Controllers/GreenField/LightningNodeApiController.Internal.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Configuration; diff --git a/BTCPayServer/Controllers/GreenField/LightningNodeApiController.Store.cs b/BTCPayServer/Controllers/GreenField/LightningNodeApiController.Store.cs index d36a3ef75..789ae8f44 100644 --- a/BTCPayServer/Controllers/GreenField/LightningNodeApiController.Store.cs +++ b/BTCPayServer/Controllers/GreenField/LightningNodeApiController.Store.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Configuration; diff --git a/BTCPayServer/Controllers/GreenField/PaymentRequestsController.cs b/BTCPayServer/Controllers/GreenField/PaymentRequestsController.cs index 583c5f978..f07a5ebb4 100644 --- a/BTCPayServer/Controllers/GreenField/PaymentRequestsController.cs +++ b/BTCPayServer/Controllers/GreenField/PaymentRequestsController.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; diff --git a/BTCPayServer/Controllers/GreenField/PullPaymentController.cs b/BTCPayServer/Controllers/GreenField/PullPaymentController.cs index e49bac3f5..4f4903bd6 100644 --- a/BTCPayServer/Controllers/GreenField/PullPaymentController.cs +++ b/BTCPayServer/Controllers/GreenField/PullPaymentController.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using BTCPayServer; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; diff --git a/BTCPayServer/Controllers/GreenField/ServerInfoController.cs b/BTCPayServer/Controllers/GreenField/ServerInfoController.cs index 6f965ca78..363f1a961 100644 --- a/BTCPayServer/Controllers/GreenField/ServerInfoController.cs +++ b/BTCPayServer/Controllers/GreenField/ServerInfoController.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.HostedServices; diff --git a/BTCPayServer/Controllers/GreenField/StoresController.cs b/BTCPayServer/Controllers/GreenField/StoresController.cs index 5d87f2c0f..ca275f719 100644 --- a/BTCPayServer/Controllers/GreenField/StoresController.cs +++ b/BTCPayServer/Controllers/GreenField/StoresController.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; diff --git a/BTCPayServer/Controllers/GreenField/TestApiKeyController.cs b/BTCPayServer/Controllers/GreenField/TestApiKeyController.cs index 804558fe9..248f17839 100644 --- a/BTCPayServer/Controllers/GreenField/TestApiKeyController.cs +++ b/BTCPayServer/Controllers/GreenField/TestApiKeyController.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Data; using BTCPayServer.Security; diff --git a/BTCPayServer/Controllers/GreenField/UsersController.cs b/BTCPayServer/Controllers/GreenField/UsersController.cs index e76cd784c..fc2aa5231 100644 --- a/BTCPayServer/Controllers/GreenField/UsersController.cs +++ b/BTCPayServer/Controllers/GreenField/UsersController.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Configuration; diff --git a/BTCPayServer/Controllers/HomeController.cs b/BTCPayServer/Controllers/HomeController.cs index ead82b648..fe2c39b61 100644 --- a/BTCPayServer/Controllers/HomeController.cs +++ b/BTCPayServer/Controllers/HomeController.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Net.Http; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Data; using BTCPayServer.HostedServices; using BTCPayServer.Models; diff --git a/BTCPayServer/Controllers/InvoiceController.API.cs b/BTCPayServer/Controllers/InvoiceController.API.cs index ea8f8e972..4d6db5029 100644 --- a/BTCPayServer/Controllers/InvoiceController.API.cs +++ b/BTCPayServer/Controllers/InvoiceController.API.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Filters; using BTCPayServer.Models; diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index f739c1f9b..79c18077b 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -6,6 +6,9 @@ using System.Net.Mime; using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Data; diff --git a/BTCPayServer/Controllers/ManageController.APIKeys.cs b/BTCPayServer/Controllers/ManageController.APIKeys.cs index 68cf4be5d..adafd5c29 100644 --- a/BTCPayServer/Controllers/ManageController.APIKeys.cs +++ b/BTCPayServer/Controllers/ManageController.APIKeys.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Data; using BTCPayServer.Models; diff --git a/BTCPayServer/Controllers/ManageController.Notifications.cs b/BTCPayServer/Controllers/ManageController.Notifications.cs index df90cecf0..9795e32bb 100644 --- a/BTCPayServer/Controllers/ManageController.Notifications.cs +++ b/BTCPayServer/Controllers/ManageController.Notifications.cs @@ -2,7 +2,9 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; diff --git a/BTCPayServer/Controllers/ManageController.U2F.cs b/BTCPayServer/Controllers/ManageController.U2F.cs index 2e4df074c..b6f1ece4e 100644 --- a/BTCPayServer/Controllers/ManageController.U2F.cs +++ b/BTCPayServer/Controllers/ManageController.U2F.cs @@ -1,4 +1,6 @@ using System.Threading.Tasks; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Models; using BTCPayServer.U2F.Models; using Microsoft.AspNetCore.Mvc; diff --git a/BTCPayServer/Controllers/ManageController.cs b/BTCPayServer/Controllers/ManageController.cs index 5fef8d0d8..ab8187ac4 100644 --- a/BTCPayServer/Controllers/ManageController.cs +++ b/BTCPayServer/Controllers/ManageController.cs @@ -1,6 +1,7 @@ using System; using System.Text.Encodings.Web; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Data; using BTCPayServer.Models.ManageViewModels; using BTCPayServer.Security; diff --git a/BTCPayServer/Controllers/NotificationsController.cs b/BTCPayServer/Controllers/NotificationsController.cs index d823bcb01..b0e3e22ca 100644 --- a/BTCPayServer/Controllers/NotificationsController.cs +++ b/BTCPayServer/Controllers/NotificationsController.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Data; using BTCPayServer.Filters; using BTCPayServer.Models.NotificationViewModels; diff --git a/BTCPayServer/Controllers/PaymentRequestController.cs b/BTCPayServer/Controllers/PaymentRequestController.cs index cedf4309d..dbf56a4d1 100644 --- a/BTCPayServer/Controllers/PaymentRequestController.cs +++ b/BTCPayServer/Controllers/PaymentRequestController.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.Events; diff --git a/BTCPayServer/Controllers/PullPaymentController.cs b/BTCPayServer/Controllers/PullPaymentController.cs index aeca1988b..ca24e3fe9 100644 --- a/BTCPayServer/Controllers/PullPaymentController.cs +++ b/BTCPayServer/Controllers/PullPaymentController.cs @@ -4,6 +4,8 @@ using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; using BTCPayServer; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Data; using BTCPayServer.HostedServices; using BTCPayServer.Models; diff --git a/BTCPayServer/Controllers/RateController.cs b/BTCPayServer/Controllers/RateController.cs index 712193734..f10a2ba8b 100644 --- a/BTCPayServer/Controllers/RateController.cs +++ b/BTCPayServer/Controllers/RateController.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Data; using BTCPayServer.Filters; using BTCPayServer.Models; @@ -20,7 +21,7 @@ using Newtonsoft.Json; namespace BTCPayServer.Controllers { [EnableCors(CorsPolicies.All)] - [Authorize(Policy = ServerPolicies.CanGetRates.Key, AuthenticationSchemes = Security.AuthenticationSchemes.Bitpay)] + [Authorize(Policy = ServerPolicies.CanGetRates.Key, AuthenticationSchemes = AuthenticationSchemes.Bitpay)] public class RateController : Controller { public StoreData CurrentStore diff --git a/BTCPayServer/Controllers/ServerController.Plugins.cs b/BTCPayServer/Controllers/ServerController.Plugins.cs index 62c3e93bd..d0d88f872 100644 --- a/BTCPayServer/Controllers/ServerController.Plugins.cs +++ b/BTCPayServer/Controllers/ServerController.Plugins.cs @@ -2,8 +2,10 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Contracts; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Configuration; -using BTCPayServer.Contracts; using BTCPayServer.Models; using BTCPayServer.Plugins; using Microsoft.AspNetCore.Http; diff --git a/BTCPayServer/Controllers/ServerController.Storage.cs b/BTCPayServer/Controllers/ServerController.Storage.cs index 8a067ab79..3af0950f0 100644 --- a/BTCPayServer/Controllers/ServerController.Storage.cs +++ b/BTCPayServer/Controllers/ServerController.Storage.cs @@ -1,6 +1,8 @@ using System; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Models; using BTCPayServer.Models.ServerViewModels; using BTCPayServer.Storage.Models; diff --git a/BTCPayServer/Controllers/ServerController.Users.cs b/BTCPayServer/Controllers/ServerController.Users.cs index a5fc5e26c..24464bd6b 100644 --- a/BTCPayServer/Controllers/ServerController.Users.cs +++ b/BTCPayServer/Controllers/ServerController.Users.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Data; using BTCPayServer.Events; using BTCPayServer.Models; diff --git a/BTCPayServer/Controllers/ServerController.cs b/BTCPayServer/Controllers/ServerController.cs index 7bb2728a7..ceb024d3a 100644 --- a/BTCPayServer/Controllers/ServerController.cs +++ b/BTCPayServer/Controllers/ServerController.cs @@ -7,6 +7,8 @@ using System.Net; using System.Net.Http; using System.Net.Mail; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Configuration; using BTCPayServer.Data; using BTCPayServer.Events; @@ -33,11 +35,12 @@ using Microsoft.Extensions.Logging; using NBitcoin; using NBitcoin.DataEncoders; using Renci.SshNet; +using AuthenticationSchemes = BTCPayServer.Abstractions.Constants.AuthenticationSchemes; namespace BTCPayServer.Controllers { [Authorize(Policy = BTCPayServer.Client.Policies.CanModifyServerSettings, - AuthenticationSchemes = BTCPayServer.Security.AuthenticationSchemes.Cookie)] + AuthenticationSchemes = AuthenticationSchemes.Cookie)] public partial class ServerController : Controller { private readonly UserManager _UserManager; diff --git a/BTCPayServer/Controllers/StoresController.BTCLike.cs b/BTCPayServer/Controllers/StoresController.BTCLike.cs index 99faddd50..e23694e26 100644 --- a/BTCPayServer/Controllers/StoresController.BTCLike.cs +++ b/BTCPayServer/Controllers/StoresController.BTCLike.cs @@ -2,6 +2,8 @@ using System; using System.IO; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Data; using BTCPayServer.Events; diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 68f18317e..886233820 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -5,6 +5,9 @@ using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Configuration; using BTCPayServer.Data; diff --git a/BTCPayServer/Controllers/UserStoresController.cs b/BTCPayServer/Controllers/UserStoresController.cs index 56d8fc2f3..6363d13b8 100644 --- a/BTCPayServer/Controllers/UserStoresController.cs +++ b/BTCPayServer/Controllers/UserStoresController.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Data; using BTCPayServer.Models; using BTCPayServer.Models.StoreViewModels; diff --git a/BTCPayServer/Controllers/WalletsController.PSBT.cs b/BTCPayServer/Controllers/WalletsController.PSBT.cs index 69ba4dcee..a897fbd0b 100644 --- a/BTCPayServer/Controllers/WalletsController.PSBT.cs +++ b/BTCPayServer/Controllers/WalletsController.PSBT.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.HostedServices; using BTCPayServer.ModelBinders; using BTCPayServer.Models; diff --git a/BTCPayServer/Controllers/WalletsController.PullPayments.cs b/BTCPayServer/Controllers/WalletsController.PullPayments.cs index 040618817..6e50d7723 100644 --- a/BTCPayServer/Controllers/WalletsController.PullPayments.cs +++ b/BTCPayServer/Controllers/WalletsController.PullPayments.cs @@ -4,6 +4,8 @@ using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Data; using BTCPayServer.HostedServices; using BTCPayServer.ModelBinders; diff --git a/BTCPayServer/Controllers/WalletsController.cs b/BTCPayServer/Controllers/WalletsController.cs index 4382ba6e8..5b94bc87f 100644 --- a/BTCPayServer/Controllers/WalletsController.cs +++ b/BTCPayServer/Controllers/WalletsController.cs @@ -4,6 +4,9 @@ using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Data; using BTCPayServer.HostedServices; diff --git a/BTCPayServer/Extensions.cs b/BTCPayServer/Extensions.cs index 4ef2bf160..9896c2240 100644 --- a/BTCPayServer/Extensions.cs +++ b/BTCPayServer/Extensions.cs @@ -9,6 +9,7 @@ using System.Security.Claims; using System.Text; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Configuration; using BTCPayServer.Data; using BTCPayServer.Lightning; diff --git a/BTCPayServer/Extensions/WebHostExtensions.cs b/BTCPayServer/Extensions/WebHostExtensions.cs index 4014c8967..6703be332 100644 --- a/BTCPayServer/Extensions/WebHostExtensions.cs +++ b/BTCPayServer/Extensions/WebHostExtensions.cs @@ -1,5 +1,6 @@ using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Hosting; using Microsoft.Extensions.DependencyInjection; diff --git a/BTCPayServer/Hosting/BTCPayServerServices.cs b/BTCPayServer/Hosting/BTCPayServerServices.cs index 8dc65230c..5100daa72 100644 --- a/BTCPayServer/Hosting/BTCPayServerServices.cs +++ b/BTCPayServer/Hosting/BTCPayServerServices.cs @@ -1,8 +1,10 @@ using System; using System.IO; using System.Threading; +using BTCPayServer.Abstractions.Contracts; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Configuration; -using BTCPayServer.Contracts; using BTCPayServer.Controllers; using BTCPayServer.Data; using BTCPayServer.HostedServices; @@ -109,20 +111,19 @@ namespace BTCPayServer.Hosting services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); - services.TryAddSingleton(o => + services.TryAddSingleton(o => { var opts = o.GetRequiredService(); - ApplicationDbContextFactory dbContext = null; if (!string.IsNullOrEmpty(opts.PostgresConnectionString)) { Logs.Configuration.LogInformation($"Postgres DB used"); - dbContext = new ApplicationDbContextFactory(DatabaseType.Postgres, opts.PostgresConnectionString); + return new DatabaseOptions(DatabaseType.Postgres, opts.PostgresConnectionString); } else if (!string.IsNullOrEmpty(opts.MySQLConnectionString)) { Logs.Configuration.LogInformation($"MySQL DB used"); Logs.Configuration.LogWarning("MySQL is not widely tested and should be considered experimental, we advise you to use postgres instead."); - dbContext = new ApplicationDbContextFactory(DatabaseType.MySQL, opts.MySQLConnectionString); + return new DatabaseOptions(DatabaseType.MySQL, opts.MySQLConnectionString); } else if (!string.IsNullOrEmpty(opts.SQLiteFileName)) { @@ -131,15 +132,14 @@ namespace BTCPayServer.Hosting : Path.Combine(opts.DataDir, opts.SQLiteFileName)); Logs.Configuration.LogInformation($"SQLite DB used"); Logs.Configuration.LogWarning("SQLite is not widely tested and should be considered experimental, we advise you to use postgres instead."); - dbContext = new ApplicationDbContextFactory(DatabaseType.Sqlite, connStr); + return new DatabaseOptions(DatabaseType.Sqlite, connStr); } else { throw new ConfigException("No database option was configured."); } - - return dbContext; }); + services.AddSingleton(); services.TryAddSingleton(o => { diff --git a/BTCPayServer/Hosting/BlockExplorerLinkStartupTask.cs b/BTCPayServer/Hosting/BlockExplorerLinkStartupTask.cs index 8099a3ff7..2f6b8b855 100644 --- a/BTCPayServer/Hosting/BlockExplorerLinkStartupTask.cs +++ b/BTCPayServer/Hosting/BlockExplorerLinkStartupTask.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Services; namespace BTCPayServer.Hosting diff --git a/BTCPayServer/Hosting/MigrationStartupTask.cs b/BTCPayServer/Hosting/MigrationStartupTask.cs index a20b7011c..1bce3c1ea 100644 --- a/BTCPayServer/Hosting/MigrationStartupTask.cs +++ b/BTCPayServer/Hosting/MigrationStartupTask.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Client.Models; using BTCPayServer.Data; using BTCPayServer.Logging; diff --git a/BTCPayServer/Models/NotificationViewModels/IndexViewModel.cs b/BTCPayServer/Models/NotificationViewModels/IndexViewModel.cs index 4183c9ed7..8f5a0a19f 100644 --- a/BTCPayServer/Models/NotificationViewModels/IndexViewModel.cs +++ b/BTCPayServer/Models/NotificationViewModels/IndexViewModel.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; namespace BTCPayServer.Models.NotificationViewModels { diff --git a/BTCPayServer/Plugins/BTCPayServerPlugin.cs b/BTCPayServer/Plugins/BTCPayServerPlugin.cs index dc0c59272..ce3b9b815 100644 --- a/BTCPayServer/Plugins/BTCPayServerPlugin.cs +++ b/BTCPayServer/Plugins/BTCPayServerPlugin.cs @@ -1,3 +1,4 @@ +using BTCPayServer.Abstractions.Models; using BTCPayServer.Models; namespace BTCPayServer.Plugins diff --git a/BTCPayServer/Plugins/PluginManager.cs b/BTCPayServer/Plugins/PluginManager.cs index 48c753491..264c6d231 100644 --- a/BTCPayServer/Plugins/PluginManager.cs +++ b/BTCPayServer/Plugins/PluginManager.cs @@ -5,8 +5,8 @@ using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Configuration; -using BTCPayServer.Contracts; using McMaster.NETCore.Plugins; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; diff --git a/BTCPayServer/Plugins/PluginService.cs b/BTCPayServer/Plugins/PluginService.cs index 84bea57be..7eec0e369 100644 --- a/BTCPayServer/Plugins/PluginService.cs +++ b/BTCPayServer/Plugins/PluginService.cs @@ -6,8 +6,8 @@ using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Configuration; -using BTCPayServer.Contracts; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; diff --git a/BTCPayServer/Security/AuthenticationExtensions.cs b/BTCPayServer/Security/AuthenticationExtensions.cs index 5c6aa80c6..0fcfc6de7 100644 --- a/BTCPayServer/Security/AuthenticationExtensions.cs +++ b/BTCPayServer/Security/AuthenticationExtensions.cs @@ -1,3 +1,4 @@ +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Security.Bitpay; using Microsoft.AspNetCore.Authentication; diff --git a/BTCPayServer/Security/CookieAuthorizationHandler.cs b/BTCPayServer/Security/CookieAuthorizationHandler.cs index ae12981c3..998c556f7 100644 --- a/BTCPayServer/Security/CookieAuthorizationHandler.cs +++ b/BTCPayServer/Security/CookieAuthorizationHandler.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using BTCPayServer.Data; using BTCPayServer.Services.Stores; diff --git a/BTCPayServer/Security/GreenField/APIKeyExtensions.cs b/BTCPayServer/Security/GreenField/APIKeyExtensions.cs index bb8136945..35a425965 100644 --- a/BTCPayServer/Security/GreenField/APIKeyExtensions.cs +++ b/BTCPayServer/Security/GreenField/APIKeyExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using BTCPayServer.Abstractions.Constants; using BTCPayServer.Client; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; diff --git a/BTCPayServer/Services/Altcoins/Ethereum/EthereumLikeExtensions.cs b/BTCPayServer/Services/Altcoins/Ethereum/EthereumLikeExtensions.cs index 2ba83d680..40e53649d 100644 --- a/BTCPayServer/Services/Altcoins/Ethereum/EthereumLikeExtensions.cs +++ b/BTCPayServer/Services/Altcoins/Ethereum/EthereumLikeExtensions.cs @@ -1,7 +1,8 @@ #if ALTCOINS using System.Net; using System.Net.Http; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; +using BTCPayServer.Abstractions.Services; using BTCPayServer.HostedServices; using BTCPayServer.Payments; using BTCPayServer.Services.Altcoins.Ethereum.Payments; diff --git a/BTCPayServer/Services/Altcoins/Ethereum/Services/EthereumSyncSummaryProvider.cs b/BTCPayServer/Services/Altcoins/Ethereum/Services/EthereumSyncSummaryProvider.cs index ea929ebe7..791269c74 100644 --- a/BTCPayServer/Services/Altcoins/Ethereum/Services/EthereumSyncSummaryProvider.cs +++ b/BTCPayServer/Services/Altcoins/Ethereum/Services/EthereumSyncSummaryProvider.cs @@ -1,5 +1,5 @@ #if ALTCOINS -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; namespace BTCPayServer.Services.Altcoins.Ethereum.Services { diff --git a/BTCPayServer/Services/Altcoins/Ethereum/UI/EthereumConfigController.cs b/BTCPayServer/Services/Altcoins/Ethereum/UI/EthereumConfigController.cs index 39f344ae0..97df2d729 100644 --- a/BTCPayServer/Services/Altcoins/Ethereum/UI/EthereumConfigController.cs +++ b/BTCPayServer/Services/Altcoins/Ethereum/UI/EthereumConfigController.cs @@ -4,6 +4,9 @@ using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Data; using BTCPayServer.Models; diff --git a/BTCPayServer/Services/Altcoins/Ethereum/UI/EthereumLikeStoreController.cs b/BTCPayServer/Services/Altcoins/Ethereum/UI/EthereumLikeStoreController.cs index e19c565fd..0b0a15723 100644 --- a/BTCPayServer/Services/Altcoins/Ethereum/UI/EthereumLikeStoreController.cs +++ b/BTCPayServer/Services/Altcoins/Ethereum/UI/EthereumLikeStoreController.cs @@ -4,6 +4,9 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Data; using BTCPayServer.Models; diff --git a/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs b/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs index b87841183..81755d430 100644 --- a/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs +++ b/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs @@ -1,8 +1,9 @@ #if ALTCOINS using System; using System.Linq; +using BTCPayServer.Abstractions.Contracts; +using BTCPayServer.Abstractions.Services; using BTCPayServer.Configuration; -using BTCPayServer.Contracts; using BTCPayServer.Payments; using BTCPayServer.Services.Altcoins.Monero.Configuration; using BTCPayServer.Services.Altcoins.Monero.Payments; diff --git a/BTCPayServer/Services/Altcoins/Monero/Services/MoneroSyncSummaryProvider.cs b/BTCPayServer/Services/Altcoins/Monero/Services/MoneroSyncSummaryProvider.cs index b1beb68f6..910ff0ea0 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Services/MoneroSyncSummaryProvider.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Services/MoneroSyncSummaryProvider.cs @@ -1,6 +1,6 @@ #if ALTCOINS using System.Linq; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; namespace BTCPayServer.Services.Altcoins.Monero.Services { diff --git a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs index 5c9fbfc58..16179c8d9 100644 --- a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs +++ b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs @@ -7,6 +7,9 @@ using System.Globalization; using System.IO; using System.Linq; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Constants; +using BTCPayServer.Abstractions.Extensions; +using BTCPayServer.Abstractions.Models; using BTCPayServer.Client; using BTCPayServer.Data; using BTCPayServer.Filters; diff --git a/BTCPayServer/Services/NBXSyncSummaryProvider.cs b/BTCPayServer/Services/NBXSyncSummaryProvider.cs index 32d4451af..a805f6394 100644 --- a/BTCPayServer/Services/NBXSyncSummaryProvider.cs +++ b/BTCPayServer/Services/NBXSyncSummaryProvider.cs @@ -1,4 +1,4 @@ -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.HostedServices; namespace BTCPayServer.Services diff --git a/BTCPayServer/Services/Notifications/Blobs/InvoiceEventNotification.cs b/BTCPayServer/Services/Notifications/Blobs/InvoiceEventNotification.cs index 4853b0f92..a4bc08e73 100644 --- a/BTCPayServer/Services/Notifications/Blobs/InvoiceEventNotification.cs +++ b/BTCPayServer/Services/Notifications/Blobs/InvoiceEventNotification.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Configuration; -using BTCPayServer.Contracts; using BTCPayServer.Controllers; using BTCPayServer.Events; using BTCPayServer.Models.NotificationViewModels; diff --git a/BTCPayServer/Services/Notifications/Blobs/JunkNotification.cs b/BTCPayServer/Services/Notifications/Blobs/JunkNotification.cs index c334377db..859cf6d48 100644 --- a/BTCPayServer/Services/Notifications/Blobs/JunkNotification.cs +++ b/BTCPayServer/Services/Notifications/Blobs/JunkNotification.cs @@ -1,6 +1,6 @@ #if DEBUG using System.Data; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; namespace BTCPayServer.Services.Notifications.Blobs { diff --git a/BTCPayServer/Services/Notifications/Blobs/NewVersionNotification.cs b/BTCPayServer/Services/Notifications/Blobs/NewVersionNotification.cs index 1959e11e8..1dced7dcc 100644 --- a/BTCPayServer/Services/Notifications/Blobs/NewVersionNotification.cs +++ b/BTCPayServer/Services/Notifications/Blobs/NewVersionNotification.cs @@ -1,4 +1,4 @@ -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Models.NotificationViewModels; namespace BTCPayServer.Services.Notifications.Blobs diff --git a/BTCPayServer/Services/Notifications/Blobs/PayoutNotification.cs b/BTCPayServer/Services/Notifications/Blobs/PayoutNotification.cs index 5708c212b..3bb47bd9f 100644 --- a/BTCPayServer/Services/Notifications/Blobs/PayoutNotification.cs +++ b/BTCPayServer/Services/Notifications/Blobs/PayoutNotification.cs @@ -1,5 +1,5 @@ +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Configuration; -using BTCPayServer.Contracts; using BTCPayServer.Controllers; using BTCPayServer.Models.NotificationViewModels; using Microsoft.AspNetCore.Routing; diff --git a/BTCPayServer/Services/Notifications/INotificationHandler.cs b/BTCPayServer/Services/Notifications/INotificationHandler.cs index abaf21b1e..40a559d07 100644 --- a/BTCPayServer/Services/Notifications/INotificationHandler.cs +++ b/BTCPayServer/Services/Notifications/INotificationHandler.cs @@ -1,5 +1,5 @@ using System; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; namespace BTCPayServer.Services.Notifications { diff --git a/BTCPayServer/Services/Notifications/NotificationManager.cs b/BTCPayServer/Services/Notifications/NotificationManager.cs index 1f548396d..86505ccf2 100644 --- a/BTCPayServer/Services/Notifications/NotificationManager.cs +++ b/BTCPayServer/Services/Notifications/NotificationManager.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Components.NotificationsDropdown; -using BTCPayServer.Contracts; using BTCPayServer.Data; using BTCPayServer.Models.NotificationViewModels; using Microsoft.AspNetCore.Identity; diff --git a/BTCPayServer/Services/Notifications/NotificationSender.cs b/BTCPayServer/Services/Notifications/NotificationSender.cs index df4583188..86b5f65dd 100644 --- a/BTCPayServer/Services/Notifications/NotificationSender.cs +++ b/BTCPayServer/Services/Notifications/NotificationSender.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using BTCPayServer.Contracts; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Data; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; diff --git a/BTCPayServer/Services/SettingsRepository.cs b/BTCPayServer/Services/SettingsRepository.cs index 6e08422fd..bb9730fad 100644 --- a/BTCPayServer/Services/SettingsRepository.cs +++ b/BTCPayServer/Services/SettingsRepository.cs @@ -1,5 +1,6 @@ using System.Threading; using System.Threading.Tasks; +using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Data; using BTCPayServer.Events; using Microsoft.EntityFrameworkCore; diff --git a/BTCPayServer/Views/Manage/NotificationSettings.cshtml b/BTCPayServer/Views/Manage/NotificationSettings.cshtml index fde970170..2ca2ea901 100644 --- a/BTCPayServer/Views/Manage/NotificationSettings.cshtml +++ b/BTCPayServer/Views/Manage/NotificationSettings.cshtml @@ -1,4 +1,4 @@ -@using BTCPayServer.Contracts +@using BTCPayServer.Abstractions.Contracts @model BTCPayServer.Controllers.ManageController.NotificationSettingsViewModel @inject IEnumerable NotificationHandlers @{ diff --git a/BTCPayServer/Views/Server/ListPlugins.cshtml b/BTCPayServer/Views/Server/ListPlugins.cshtml index 6588587eb..bcf00c94c 100644 --- a/BTCPayServer/Views/Server/ListPlugins.cshtml +++ b/BTCPayServer/Views/Server/ListPlugins.cshtml @@ -1,5 +1,5 @@ @using BTCPayServer.Configuration -@using BTCPayServer.Contracts +@using BTCPayServer.Abstractions.Contracts @model BTCPayServer.Controllers.ServerController.ListPluginsViewModel @inject BTCPayServerOptions BTCPayServerOptions @{ diff --git a/BTCPayServer/Views/Shared/LayoutPartials/SyncModal.cshtml b/BTCPayServer/Views/Shared/LayoutPartials/SyncModal.cshtml index efc7ec532..0c744f7e3 100644 --- a/BTCPayServer/Views/Shared/LayoutPartials/SyncModal.cshtml +++ b/BTCPayServer/Views/Shared/LayoutPartials/SyncModal.cshtml @@ -1,4 +1,4 @@ -@using BTCPayServer.Contracts +@using BTCPayServer.Abstractions.Contracts @inject IEnumerable SyncSummaryProviders; @if (SyncSummaryProviders.Any(provider => !provider.AllAvailable())) {