diff --git a/src/OnlineSales/Controllers/AccountsController.cs b/src/OnlineSales/Controllers/AccountsController.cs index e1482814..dca7b765 100644 --- a/src/OnlineSales/Controllers/AccountsController.cs +++ b/src/OnlineSales/Controllers/AccountsController.cs @@ -5,8 +5,6 @@ using AutoMapper; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Options; -using OnlineSales.Configuration; using OnlineSales.Data; using OnlineSales.DTOs; using OnlineSales.Entities; diff --git a/src/OnlineSales/Controllers/BaseController.cs b/src/OnlineSales/Controllers/BaseController.cs index 6817daf3..1709c757 100644 --- a/src/OnlineSales/Controllers/BaseController.cs +++ b/src/OnlineSales/Controllers/BaseController.cs @@ -22,7 +22,7 @@ public class BaseController : ControllerBase protected readonly DbSet dbSet; protected readonly PgDbContext dbContext; protected readonly IMapper mapper; - private readonly QueryProviderFactory queryProviderFactory; + protected readonly QueryProviderFactory queryProviderFactory; public BaseController(PgDbContext dbContext, IMapper mapper, EsDbContext esDbContext, QueryProviderFactory queryProviderFactory) { diff --git a/src/OnlineSales/Entities/Comment.cs b/src/OnlineSales/Entities/Comment.cs index 486bdaaa..da457903 100644 --- a/src/OnlineSales/Entities/Comment.cs +++ b/src/OnlineSales/Entities/Comment.cs @@ -19,7 +19,7 @@ public enum CommentStatus [Table("comment")] [SupportsElastic] [SupportsChangeLog] -[SurrogateIdentityAttribute(nameof(Key))] +[SurrogateIdentity(nameof(Key))] public class Comment : BaseEntity { private string authorEmail = string.Empty; diff --git a/src/OnlineSales/Entities/Content.cs b/src/OnlineSales/Entities/Content.cs index d827d972..9673e9cd 100644 --- a/src/OnlineSales/Entities/Content.cs +++ b/src/OnlineSales/Entities/Content.cs @@ -4,7 +4,6 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Text.Json.Serialization; using Microsoft.EntityFrameworkCore; using Nest; using OnlineSales.DataAnnotations; diff --git a/src/OnlineSales/Infrastructure/ESOnlyQueryProviderFactory.cs b/src/OnlineSales/Infrastructure/ESOnlyQueryProviderFactory.cs index ddc9021f..74207e85 100644 --- a/src/OnlineSales/Infrastructure/ESOnlyQueryProviderFactory.cs +++ b/src/OnlineSales/Infrastructure/ESOnlyQueryProviderFactory.cs @@ -3,12 +3,9 @@ // using System.Web; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; -using Nest; using OnlineSales.Configuration; using OnlineSales.Data; -using OnlineSales.DataAnnotations; using OnlineSales.Entities; using OnlineSales.Interfaces; diff --git a/src/OnlineSales/Infrastructure/QueryProviderFactory.cs b/src/OnlineSales/Infrastructure/QueryProviderFactory.cs index ad745873..f0c96815 100644 --- a/src/OnlineSales/Infrastructure/QueryProviderFactory.cs +++ b/src/OnlineSales/Infrastructure/QueryProviderFactory.cs @@ -3,7 +3,6 @@ // using System.Web; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using Nest; using OnlineSales.Configuration; @@ -18,9 +17,10 @@ public class QueryProviderFactory where T : BaseEntityWithId, new() { protected readonly IOptions apiSettingsConfig; - protected readonly IHttpContextHelper httpContextHelper; - protected readonly PgDbContext dbContext; - protected readonly ElasticClient elasticClient; + protected readonly IHttpContextHelper httpContextHelper; + protected readonly ElasticClient elasticClient; + + protected PgDbContext dbContext; public QueryProviderFactory(PgDbContext dbContext, EsDbContext esDbContext, IOptions apiSettingsConfig, IHttpContextHelper? httpContextHelper) { @@ -51,5 +51,10 @@ public virtual IQueryProvider BuildQueryProvider(int limit = -1) return new DBQueryProvider(dbSet!.AsQueryable(), queryBuilder); } } + + public void SetDBContext(PgDbContext dbContext) + { + this.dbContext = dbContext; + } } } diff --git a/src/OnlineSales/Infrastructure/TaskRunner.cs b/src/OnlineSales/Infrastructure/TaskRunner.cs index e9df0d11..b6ecd0c3 100644 --- a/src/OnlineSales/Infrastructure/TaskRunner.cs +++ b/src/OnlineSales/Infrastructure/TaskRunner.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the samples root for full license information. // -using System.Diagnostics.CodeAnalysis; using Medallion.Threading.Postgres; using Microsoft.EntityFrameworkCore; using OnlineSales.Data; diff --git a/src/OnlineSales/Migrations/PgDbContextModelSnapshot.cs b/src/OnlineSales/Migrations/PgDbContextModelSnapshot.cs index 4f7d4ee3..722adb53 100644 --- a/src/OnlineSales/Migrations/PgDbContextModelSnapshot.cs +++ b/src/OnlineSales/Migrations/PgDbContextModelSnapshot.cs @@ -19,7 +19,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("ProductVersion", "7.0.9") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); diff --git a/src/OnlineSales/OnlineSales.csproj b/src/OnlineSales/OnlineSales.csproj index 9cf9d902..888055a6 100644 --- a/src/OnlineSales/OnlineSales.csproj +++ b/src/OnlineSales/OnlineSales.csproj @@ -88,7 +88,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/OnlineSales/Services/ActivityLogService.cs b/src/OnlineSales/Services/ActivityLogService.cs index 6a2da153..8a483d89 100644 --- a/src/OnlineSales/Services/ActivityLogService.cs +++ b/src/OnlineSales/Services/ActivityLogService.cs @@ -2,13 +2,8 @@ // Licensed under the MIT license. See LICENSE file in the samples root for full license information. // -using System.Configuration; -using System.Diagnostics; -using Microsoft.Identity.Client; using Nest; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using OnlineSales.Data; -using OnlineSales.DTOs; using OnlineSales.Entities; namespace OnlineSales.Services