diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 045d954..f0b0f7c 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -18,9 +18,9 @@
latest
https://github.com/arsalanfallahpour/DotNetCenter.Beyond.git
- 0.1.15
- 0.1.15
- 0.1.15
+ 0.2.12
+ 0.2.12
+ 0.2.12
3.3.2
3.9.0-2.final
@@ -79,7 +79,7 @@
0.2.1
- 0.2.2
+ 0.2.7
0.2.2
8.1.1
diff --git a/src/Mediation/Behaviours/Source/DotNetCenter.Beyond.Mediation.Behaviours.csproj b/src/Mediation/Behaviours/Source/DotNetCenter.Beyond.Mediation.Behaviours.csproj
index 2386553..77089ed 100644
--- a/src/Mediation/Behaviours/Source/DotNetCenter.Beyond.Mediation.Behaviours.csproj
+++ b/src/Mediation/Behaviours/Source/DotNetCenter.Beyond.Mediation.Behaviours.csproj
@@ -72,8 +72,11 @@
+
+
+
diff --git a/src/Mediation/Behaviours/Source/RequestLogger.cs b/src/Mediation/Behaviours/Source/RequestLogger.cs
index c9beff1..8341edf 100644
--- a/src/Mediation/Behaviours/Source/RequestLogger.cs
+++ b/src/Mediation/Behaviours/Source/RequestLogger.cs
@@ -8,17 +8,20 @@ namespace DotNetCenter.Beyond.Mediation.Behaviours
using DotNetCenter.Beyond.Web.Identity.Core;
using System;
using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DbContextServices;
+ using DotNetCenter.Beyond.Web.Identity.Services;
+ using DotNetCenter.Beyond.Web.Identity.Services.Managers;
+ using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
public class RequestLogger : IRequestPreProcessor
{
private readonly ILogger _logger;
private readonly CurrentUserService _currentUserService;
- private readonly IdentityService _identityService;
+ private readonly IdentityService _identityService;
public RequestLogger(
ILogger logger,
CurrentUserService currentUserService,
- IdentityService identityService)
+ IdentityService identityService)
{
_logger = logger;
_currentUserService = currentUserService;
@@ -26,8 +29,14 @@ public RequestLogger(
}
public async Task Process(TRequest request, CancellationToken cancellationToken)
{
- var userName = await _identityService.GetUsernameAsync(_currentUserService.UserId);
- _logger.LogInformation("Request: {Name} {@UserId} {@UserName} {@Request}", typeof(TRequest).Name, _currentUserService.UserId, userName, request);
+ int? userId = -9845;
+ var userName = "Not Authorized User";
+ if (_currentUserService.IsUserAuthenticated())
+ {
+ userId = _currentUserService.UserId;
+ userName = await _identityService.GetUsernameAsync((int)_currentUserService.UserId);
+ }
+ _logger.LogInformation("Request: {Name} {@UserId} {@UserName} {@Request}", typeof(TRequest).Name, userId, userName, request);
}
}
}
diff --git a/src/Mediation/Behaviours/Source/RequestPerformanceBehaviour.cs b/src/Mediation/Behaviours/Source/RequestPerformanceBehaviour.cs
index 433340a..a084dc9 100644
--- a/src/Mediation/Behaviours/Source/RequestPerformanceBehaviour.cs
+++ b/src/Mediation/Behaviours/Source/RequestPerformanceBehaviour.cs
@@ -8,18 +8,23 @@
using MediatR;
using System;
using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DbContextServices;
+ using DotNetCenter.Beyond.Web.Identity.Services.Managers;
+ using System.Security.Principal;
+ using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+ using DotNetCenter.Beyond.Web.Identity.Services;
+
public class RequestPerfObjRelMappinganceBehaviour
: IPipelineBehavior
{
private readonly Stopwatch _timer;
private readonly ILogger _logger;
private readonly CurrentUserService _currentUserService;
- private readonly IdentityService _identityService;
+ private readonly IdentityService _identityService;
public RequestPerfObjRelMappinganceBehaviour(
ILogger logger,
CurrentUserService currentUserService,
- IdentityService identityService)
+ IdentityService identityService)
{
_timer = new Stopwatch();
_logger = logger;
@@ -49,17 +54,17 @@ private async Task LogRequestLongRunning(TRequest request)
{
var logMessage = "Application Long Running Request: {Name} ({ElapsedMilliseconds} milliseconds) {@UserId}";
var requestName = typeof(TRequest).Name;
- if (_currentUserService.TrySetUserId())
+ //if (_currentUserService.TrySetUserId())
await LogCriticalWithUserName(request, _timer.ElapsedMilliseconds, logMessage, requestName);
- else
- _logger.LogCritical(logMessage + "{@Request}", requestName, _timer.ElapsedMilliseconds, request);
+ //else
+ // _logger.LogCritical(logMessage + "{@Request}", requestName, _timer.ElapsedMilliseconds, request);
}
private async Task LogCriticalWithUserName(TRequest request, long elapsedMilliseconds, string logMessage, string requestName)
{
var userId = _currentUserService.UserId;
- if (_currentUserService.TrySetUsername())
- _logger.LogCritical(logMessage + "{@UserName} {@Request}", requestName, elapsedMilliseconds, userId, _currentUserService.Username, request);
+ var username = _currentUserService?.Username ?? "UnAuthorized User %!%";
+ _logger.LogCritical(logMessage + "{@UserName} {@Request}", requestName, elapsedMilliseconds, userId, username, request);
}
}
}
diff --git a/src/ObjRelMapping/Core/Source/Auditing/AuditableDbService.cs b/src/ObjRelMapping/Core/Source/Auditing/AuditableDbService.cs
index 71ef2fe..95ed36f 100644
--- a/src/ObjRelMapping/Core/Source/Auditing/AuditableDbService.cs
+++ b/src/ObjRelMapping/Core/Source/Auditing/AuditableDbService.cs
@@ -4,10 +4,11 @@ namespace DotNetCenter.Beyond.ObjRelMapping.Core.DbContext
using System;
using System.Threading;
using System.Threading.Tasks;
- public interface AuditableDbService
+ public interface AuditableDbService
: IDisposable, IAsyncDisposable, AuditableDbContext, EntryableDbContext, SetableDbContext
{
void Save();
+ Task SaveAsync();
Task SaveAsync(CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/ObjRelMapping/Core/Source/Auditing/BaseAuditableDbContext.cs b/src/ObjRelMapping/Core/Source/Auditing/BaseAuditableDbContext.cs
index 5b5a384..51f3c7b 100644
--- a/src/ObjRelMapping/Core/Source/Auditing/BaseAuditableDbContext.cs
+++ b/src/ObjRelMapping/Core/Source/Auditing/BaseAuditableDbContext.cs
@@ -7,7 +7,7 @@
using System.Threading.Tasks;
public abstract class BaseAuditableDbContext
: DbContext
- , AuditableDbService
+ , AuditableDbService
where TContext : DbContext
{
private readonly string _defaultSchema;
@@ -24,15 +24,16 @@ protected override void OnModelCreating(ModelBuilder builder)
{
if (!string.IsNullOrEmpty(_defaultSchema) && !string.IsNullOrWhiteSpace(_defaultSchema))
builder.HasDefaultSchema(_defaultSchema);
+ else
+ builder.HasDefaultSchema("dbo");
//builder.ApplyConfigurationsFromAssembly(typeof(DatabaseService<>).Assembly);
base.OnModelCreating(builder);
}
- public void Audit()
- => _auditor.UpdateModifiedAll(ChangeTracker);
+ public virtual void Audit() => _auditor.UpdateModifiedAll(ChangeTracker);
public abstract void Save();
-
+ public abstract Task SaveAsync();
public abstract Task SaveAsync(CancellationToken cancellationToken = default);
}
}
diff --git a/src/ObjRelMapping/Core/Source/DbContext/BaseDbContext.cs b/src/ObjRelMapping/Core/Source/DbContext/BaseDbContext.cs
index 4ead355..25fad02 100644
--- a/src/ObjRelMapping/Core/Source/DbContext/BaseDbContext.cs
+++ b/src/ObjRelMapping/Core/Source/DbContext/BaseDbContext.cs
@@ -2,28 +2,43 @@
{
using DotNetCenter.Beyond.ObjRelMapping.Core.DbContext;
using Microsoft.EntityFrameworkCore;
+ using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
- public abstract class BaseDbContext : DbContext, DbService
+ public abstract class BaseDbContext : DbContext, DbService
where TContext
: DbContext
{
- private readonly string _defaultSchema;
-
+ public virtual string Schema => _defaultSchema;
+ public readonly string _defaultSchema;
+ public abstract Assembly ConfigurationAssemby { get; }
+ public abstract bool UseAssemblyToScanConfigurations { get; }
+ public abstract bool EnableSensitiveDataLogging { get; }
public BaseDbContext(DbContextOptions options, string defaultSchema = "dbo")
: base(options)
=> _defaultSchema = defaultSchema;
-
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ base.OnConfiguring(optionsBuilder);
+ optionsBuilder.EnableSensitiveDataLogging(UseAssemblyToScanConfigurations);
+ }
protected override void OnModelCreating(ModelBuilder builder)
{
+ base.OnModelCreating(builder);
+
if (!string.IsNullOrEmpty(_defaultSchema) && !string.IsNullOrWhiteSpace(_defaultSchema))
builder.HasDefaultSchema(_defaultSchema);
+ else
+ builder.HasDefaultSchema("dbo");
- base.OnModelCreating(builder);
+
+ if (UseAssemblyToScanConfigurations)
+ builder.ApplyConfigurationsFromAssembly(ConfigurationAssemby);
}
public abstract void Save();
+ public abstract Task SaveAsync();
public abstract Task SaveAsync(CancellationToken cancellationToken = default);
}
}
diff --git a/src/ObjRelMapping/Core/Source/DbContext/DbService.cs b/src/ObjRelMapping/Core/Source/DbContext/DbService.cs
index e5ba19b..a121970 100644
--- a/src/ObjRelMapping/Core/Source/DbContext/DbService.cs
+++ b/src/ObjRelMapping/Core/Source/DbContext/DbService.cs
@@ -2,11 +2,17 @@ namespace DotNetCenter.Beyond.ObjRelMapping.Core.DbContext
{
using DotNetCenter.Beyond.ObjRelMapping.Core.Auditing;
using System;
+ using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
- public interface DbService : IDisposable, IAsyncDisposable, EntryableDbContext, SetableDbContext
+ public interface DbService: IDisposable, IAsyncDisposable, EntryableDbContext, SetableDbContext
{
void Save();
+ Task SaveAsync();
Task SaveAsync(CancellationToken cancellationToken = default);
+ public string Schema { get; }
+ public Assembly ConfigurationAssemby { get; }
+ public bool UseAssemblyToScanConfigurations { get; }
+ public bool EnableSensitiveDataLogging { get; }
}
}
\ No newline at end of file
diff --git a/src/ObjRelMapping/Core/Source/DbContext/DesignTime/DefaultDesignTimeDbContextFactoryBase.cs b/src/ObjRelMapping/Core/Source/DbContext/DesignTime/DefaultDesignTimeDbContextFactoryBase.cs
index ace11a2..71d082b 100644
--- a/src/ObjRelMapping/Core/Source/DbContext/DesignTime/DefaultDesignTimeDbContextFactoryBase.cs
+++ b/src/ObjRelMapping/Core/Source/DbContext/DesignTime/DefaultDesignTimeDbContextFactoryBase.cs
@@ -17,9 +17,17 @@ public override TContext CreateDbContext(string[] args)
.AddJsonFile($"appsettings.{applicationEnvironment}.json", true)
.AddEnvironmentVariables()
.Build();
- var path = args[1];
- basePath = path;
- Console.WriteLine($"base path : {basePath}");
+ if (args.Length == 1)
+ {
+ basePath = args[0] + $"{separator}";
+ Console.WriteLine($"base path : {basePath}");
+ }
+ if (args.Length == 2)
+ {
+ basePath = args[1] + $"{separator}";
+ Console.WriteLine($"base path : {basePath}");
+ }
+
return Create(configuration);
}
}
diff --git a/src/ObjRelMapping/Core/Source/DbInitializer.cs b/src/ObjRelMapping/Core/Source/DbInitializer.cs
index 5ad571e..99f10bc 100644
--- a/src/ObjRelMapping/Core/Source/DbInitializer.cs
+++ b/src/ObjRelMapping/Core/Source/DbInitializer.cs
@@ -1,9 +1,9 @@
namespace DotNetCenter.Beyond.ObjRelMapping.Core
{
using DotNetCenter.Beyond.ObjRelMapping.Core.DbContext;
- public interface DbInitializer
+ public interface DbInitializer
{
- public void Initialize(DbService context);
- public void SeedEverything(DbService context);
+ public void Initialize(DbService context);
+ public void SeedEverything(DbService context);
}
}
\ No newline at end of file
diff --git a/src/ObjRelMapping/Core/Source/DotNetCenter.Beyond.ObjRelMapping.Core.csproj b/src/ObjRelMapping/Core/Source/DotNetCenter.Beyond.ObjRelMapping.Core.csproj
index 49fa8cc..b6bad0e 100644
--- a/src/ObjRelMapping/Core/Source/DotNetCenter.Beyond.ObjRelMapping.Core.csproj
+++ b/src/ObjRelMapping/Core/Source/DotNetCenter.Beyond.ObjRelMapping.Core.csproj
@@ -59,6 +59,7 @@
+
@@ -66,6 +67,7 @@
+
@@ -74,13 +76,11 @@
+
-
-
-
diff --git a/src/ObjRelMapping/Core/Source/Infrastructure/Common/IAppUser.cs b/src/ObjRelMapping/Core/Source/Infrastructure/Common/IAppUser.cs
new file mode 100644
index 0000000..4572a61
--- /dev/null
+++ b/src/ObjRelMapping/Core/Source/Infrastructure/Common/IAppUser.cs
@@ -0,0 +1,18 @@
+
+namespace DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common
+{
+ using DotNetCenter.Core.Entities;
+ using System;
+ using System.Collections.Generic;
+
+ public interface IAppUser: InfrastructureDao, AuditableEntity, TrackableEntity
+ where TKeyUser : struct, IEquatable
+ where TKeyAuditor : struct, IEquatable
+ {
+ public string Tag { get; }
+ public string UserName { get; }
+ public string Email { get; }
+ public string DisplayName { get; }
+ //public bool ValidateIdentityUser();
+ }
+}
\ No newline at end of file
diff --git a/src/ObjRelMapping/Core/Source/Infrastructure/Common/IDataAccessObject.cs b/src/ObjRelMapping/Core/Source/Infrastructure/Common/IDataAccessObject.cs
new file mode 100644
index 0000000..bab6908
--- /dev/null
+++ b/src/ObjRelMapping/Core/Source/Infrastructure/Common/IDataAccessObject.cs
@@ -0,0 +1,12 @@
+using DotNetCenter.Core;
+using DotNetCenter.Core.Entities;
+using System;
+using Sys = System;
+
+namespace DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common
+{
+ public interface IDataAccessObject : Entity
+ where TKey : IEquatable
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/ObjRelMapping/Core/Source/Infrastructure/Common/InfrastructureDao.cs b/src/ObjRelMapping/Core/Source/Infrastructure/Common/InfrastructureDao.cs
new file mode 100644
index 0000000..78924aa
--- /dev/null
+++ b/src/ObjRelMapping/Core/Source/Infrastructure/Common/InfrastructureDao.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common
+{
+ public interface InfrastructureDao
+ where TKey : IEquatable
+ {
+ }
+}
diff --git a/src/ObjRelMapping/Core/Source/Infrastructure/Common/PersistableObject.cs b/src/ObjRelMapping/Core/Source/Infrastructure/Common/PersistableObject.cs
new file mode 100644
index 0000000..b102964
--- /dev/null
+++ b/src/ObjRelMapping/Core/Source/Infrastructure/Common/PersistableObject.cs
@@ -0,0 +1,11 @@
+using DotNetCenter.Core.Entities;
+using System;
+
+namespace DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common
+{
+ public interface PersistableObject : InfrastructureDao, IDataAccessObject, AuditableEntity
+ where TKey : struct, IEquatable
+ where TKeyAuditor : struct, IEquatable
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/ObjRelMapping/Core/Source/Infrastructure/Common/TrackableEntity.cs b/src/ObjRelMapping/Core/Source/Infrastructure/Common/TrackableEntity.cs
new file mode 100644
index 0000000..7efb778
--- /dev/null
+++ b/src/ObjRelMapping/Core/Source/Infrastructure/Common/TrackableEntity.cs
@@ -0,0 +1,6 @@
+namespace DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common
+{
+ public interface TrackableEntity
+ {
+ }
+}
diff --git a/src/ObjRelMapping/Core/Source/Infrastructure/Configuration/AppConfiguration.cs b/src/ObjRelMapping/Core/Source/Infrastructure/Configuration/AppConfiguration.cs
new file mode 100644
index 0000000..b2deae4
--- /dev/null
+++ b/src/ObjRelMapping/Core/Source/Infrastructure/Configuration/AppConfiguration.cs
@@ -0,0 +1,15 @@
+using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using System;
+
+namespace DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Configuration
+{
+ internal interface AppConfiguration
+ where T : class
+ where TKeyEntity : IEquatable
+ {
+ public void Configure(EntityTypeBuilder builder);
+
+ }
+}
\ No newline at end of file
diff --git a/src/ObjRelMapping/Core/Source/Infrastructure/Configuration/BaseDataAccessObject.cs b/src/ObjRelMapping/Core/Source/Infrastructure/Configuration/BaseDataAccessObject.cs
new file mode 100644
index 0000000..ea0c1c1
--- /dev/null
+++ b/src/ObjRelMapping/Core/Source/Infrastructure/Configuration/BaseDataAccessObject.cs
@@ -0,0 +1,16 @@
+using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Configuration
+{
+ public abstract class BaseDataAccessObject : InfrastructureDao
+ where TKey : IEquatable
+
+ {
+ public virtual TKey Id { get; set; }
+ }
+}
diff --git a/src/ObjRelMapping/Core/Source/Infrastructure/Configuration/BaseEntityConfiguration.cs b/src/ObjRelMapping/Core/Source/Infrastructure/Configuration/BaseEntityConfiguration.cs
new file mode 100644
index 0000000..b28b488
--- /dev/null
+++ b/src/ObjRelMapping/Core/Source/Infrastructure/Configuration/BaseEntityConfiguration.cs
@@ -0,0 +1,195 @@
+using DotNetCenter.Beyond.ObjRelMapping.Core.Auditing;
+using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
+using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Configuration;
+using DotNetCenter.Core;
+using DotNetCenter.Core.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using System;
+using System.ComponentModel;
+
+namespace DotNetCenter.Beyond.ObjRelMapping.Infrastructure.Configuration
+{
+ public abstract class BaseEntityConfiguration
+ : IEntityTypeConfiguration
+ , AppConfiguration
+ where T : class, Entity
+ where TKeyEntity : struct, IEquatable
+ {
+ // use constructor blow for single context ef apps
+ //public BaseAppConfigurastion(string tableName)
+ //{
+ // _tableName = tableName;
+ //}
+ ///
+ /// Schema must configred in ef apps that use multi context with different schamas,
+ /// also all configurtins of schemas must configured on all context that used eachother entity
+ ///
+ ///
+ ///
+ ///
+ public BaseEntityConfiguration(string tableName, string schemaName, bool configureKey = true)
+ {
+ _tableName = tableName;
+ _schemaName = schemaName;
+ _configureKey = configureKey;
+ }
+ public BaseEntityConfiguration(bool configureKey = true)
+ {
+ _tableName = string.Empty;
+ _schemaName = string.Empty;
+ _configureKey = configureKey;
+
+ }
+ public string TableName => _tableName;
+ private readonly string _tableName;
+ public string SchemaName => _schemaName;
+ private readonly string _schemaName;
+ public virtual int IdColumnSeed => 1;
+ public virtual int IdColumnIncrement => 1;
+ public bool ConfigureKey => _configureKey;
+ private readonly bool _configureKey;
+ public virtual void Configure(EntityTypeBuilder builder)
+ {
+ if (!string.IsNullOrEmpty(TableName))
+ {
+
+ if (string.IsNullOrEmpty(SchemaName))
+ builder.ToTable(TableName);
+ else
+ builder.ToTable(TableName, SchemaName);
+
+ if (_configureKey)
+ {
+ builder
+ .HasKey(o => o.Id);
+ builder
+ .Property(o => o.Id)
+#if NET5_0
+ .UseIdentityColumn(IdColumnSeed, IdColumnIncrement)
+#elif NETCOREAPP3_1_OR_GREATER
+ .UseSqlServerIdentityColumn(IdColumnSeed, IdColumnIncrement)
+#endif
+ .ValueGeneratedOnAdd();
+ }
+ }
+ }
+ }
+ public abstract class BaseEntityConfiguration
+ : IEntityTypeConfiguration
+ , AppConfiguration
+ where T : class, PersistableObject
+ where TKeyEntity : struct, IEquatable
+ where TKeyUser : struct, IEquatable
+ where TKeyAuditor : struct, IEquatable
+ {
+ // use constructor blow for single context ef apps
+ //public BaseAppConfigurastion(string tableName)
+ //{
+ // _tableName = tableName;
+ //}
+ ///
+ /// Schema must configred in ef apps that use multi context with different schamas,
+ /// also all configurtins of schemas must configured on all context that used eachother entity
+ /// Auditable Configuration
+ ///
+ ///
+ ///
+ ///
+ ///
+ public BaseEntityConfiguration(string tableName, string schemaName, bool includeAuditColumns = true, bool configureKey = true)
+ {
+ _tableName = tableName;
+ _schemaName = schemaName;
+ _includeAuditColumns = includeAuditColumns;
+ _configureKey = configureKey;
+ }
+ public BaseEntityConfiguration(bool includeAuditColumns = true, bool configureKey = true)
+ {
+ _tableName = string.Empty;
+ _schemaName = string.Empty;
+ _includeAuditColumns = includeAuditColumns;
+ _configureKey = configureKey;
+ }
+ public string TableName => _tableName;
+ private readonly string _tableName;
+ public string SchemaName => _schemaName;
+ private readonly string _schemaName;
+ public bool IncludeAuditColumns => _includeAuditColumns;
+ private readonly bool _includeAuditColumns;
+ public bool ConfigureKey => _configureKey;
+ private readonly bool _configureKey;
+ public virtual int IdColumnSeed => 1;
+ public virtual int IdColumnIncrement => 1;
+ public virtual void Configure(EntityTypeBuilder builder)
+ {
+ if (!string.IsNullOrEmpty(TableName))
+ {
+
+ if (string.IsNullOrEmpty(SchemaName))
+ builder.ToTable(TableName);
+ else
+ builder.ToTable(TableName, SchemaName);
+
+ }
+ if (_configureKey)
+ {
+ builder
+ .HasKey(o => o.Id);
+ builder
+ .Property(o => o.Id)
+#if NET5_0
+ .UseIdentityColumn(IdColumnSeed, IdColumnIncrement)
+#elif NETCOREAPP3_1_OR_GREATER
+ .UseSqlServerIdentityColumn(IdColumnSeed, IdColumnIncrement)
+#endif
+ .ValueGeneratedOnAdd();
+ }
+
+ //if (typeof(int) == typeof(TEntityKey)
+ // || typeof(short) == entityType
+ // || typeof(long) == entityType
+ // || typeof(byte) == entityType)
+
+ var entityType = typeof(T);
+ var entityName = entityType.Name;
+
+
+
+ if (_includeAuditColumns)
+ {
+ builder
+ .Property(o => o.CreatedDateTime)
+ .IsRequired();
+
+ builder
+ .Property(o => o.CreatedBy)
+ .IsRequired(true);
+
+
+ builder
+ .Property(o => o.ModifiedDateTime)
+ .IsRequired(false);
+ builder
+ .Property(o => o.ModifiedBy)
+ .IsRequired(false);
+
+ }
+ else
+ IgnoreAuditColumns(builder);
+
+ }
+ protected virtual void IgnoreAuditColumns(EntityTypeBuilder builder)
+ {
+ builder
+ .Ignore(o => o.CreatedDateTime);
+ builder
+ .Ignore(o => o.CreatedBy);
+ builder
+ .Ignore(o => o.ModifiedBy);
+ builder
+ .Ignore(o => o.ModifiedDateTime);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ObjRelMapping/Core/Source/Repository/BaseRepository.cs b/src/ObjRelMapping/Core/Source/Repository/BaseRepository.cs
index eeec8e5..57b7f25 100644
--- a/src/ObjRelMapping/Core/Source/Repository/BaseRepository.cs
+++ b/src/ObjRelMapping/Core/Source/Repository/BaseRepository.cs
@@ -11,10 +11,10 @@
public class BaseRepository : RepositoryService
where TKey : struct
where TEntity : class, Entity
- where TContext : DbService
+ where TContext : DbService
{
- protected readonly DbService _dbService;
- public BaseRepository(DbService dbService)
+ protected readonly DbService _dbService;
+ public BaseRepository(TContext dbService)
=> _dbService = dbService;
public async Task GetByIdAsync(TKey id)
=> await _dbService.Set().FindAsync(id);
diff --git a/src/ObjRelMapping/Core/Source/Repository/RepositoryService.cs b/src/ObjRelMapping/Core/Source/Repository/RepositoryService.cs
index 2fcc8ab..275fecc 100644
--- a/src/ObjRelMapping/Core/Source/Repository/RepositoryService.cs
+++ b/src/ObjRelMapping/Core/Source/Repository/RepositoryService.cs
@@ -10,7 +10,7 @@ public interface RepositoryService
: UpdateableRepository,
DeletableRepository,
AddableRepository
- where TContext : DbService
+ where TContext : DbService
where TEntity : Entity
where TKey : struct
{
diff --git a/src/Web/Core/Source/ApplicationStartup/BaseAppStartup.cs b/src/Web/Core/Source/ApplicationStartup/BaseAppStartup.cs
index e456ec4..43ff722 100644
--- a/src/Web/Core/Source/ApplicationStartup/BaseAppStartup.cs
+++ b/src/Web/Core/Source/ApplicationStartup/BaseAppStartup.cs
@@ -1,4 +1,4 @@
-using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -10,17 +10,13 @@
namespace DotNetCenter.Beyond.Web.Core.Common
{
- public abstract class BaseAppStartup : IAppStartup
+ public abstract class BaseAppStartup : IAppStartup
{
- public BaseAppStartup(SupportConfiguration configuration, SupportWebHosting webHosting, ILoggerFactory logger)
- {
- Configuration = configuration;
- WebHosting = webHosting;
- LoggerFactory = logger;
- }
- public SupportConfiguration Configuration { get; }
- public SupportWebHosting WebHosting { get; }
- public ILoggerFactory LoggerFactory { get; }
+ public BaseAppStartup(SupportPreConfiguration providedServices)
+ => _preProvidedServices = providedServices;
+
+ public SupportPreConfiguration PreProvidedServices => _preProvidedServices;
+ private readonly SupportPreConfiguration _preProvidedServices;
public abstract void ConfigureServices(IServiceCollection services);
public abstract void Configure(IApplicationBuilder app);
}
diff --git a/src/Web/Core/Source/ApplicationStartup/IAppStartup.cs b/src/Web/Core/Source/ApplicationStartup/IAppStartup.cs
index 61a9a1d..70d2da7 100644
--- a/src/Web/Core/Source/ApplicationStartup/IAppStartup.cs
+++ b/src/Web/Core/Source/ApplicationStartup/IAppStartup.cs
@@ -1,6 +1,6 @@
namespace DotNetCenter.Beyond.Web.Core.Common
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+ using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
@@ -11,9 +11,9 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
- public interface IAppStartup
+ public interface IAppStartup
{
- TConfiguration Configuration { get; }
+ SupportPreConfiguration PreProvidedServices { get; }
void ConfigureServices(IServiceCollection services);
void Configure(IApplicationBuilder app);
}
diff --git a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AllDotNetCenterDIC.cs b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AllDotNetCenterDIC.cs
index 621a4f7..46f8ff9 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AllDotNetCenterDIC.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AllDotNetCenterDIC.cs
@@ -1,7 +1,5 @@
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.DependencyContainers
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.DependencyContainers;
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
diff --git a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AspNetCoreDIC.cs b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AspNetCoreDIC.cs
index be943a0..065bf92 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AspNetCoreDIC.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AspNetCoreDIC.cs
@@ -1,6 +1,5 @@
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.DependencyContainers
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services;
using DotNetCenter.Beyond.Web.Core.Controllers;
using Microsoft.Extensions.DependencyInjection;
@@ -14,10 +13,9 @@ public class AspNetCoreDIC
{
public void AddAspNetCoreService(ref IServiceCollection services)
{
- services.AddWebHostingService();
services.AddTransient();
- services.AddSingleton();
services.AddTransient(typeof(SupportLoggingServices<>), typeof(LoggingService<>));
+ services.TryAddLoggerProviderServices();
}
}
}
diff --git a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AutoMapperDIC.cs b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AutoMapperDIC.cs
index 547fbe0..4849792 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AutoMapperDIC.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/AutoMapperDIC.cs
@@ -1,6 +1,6 @@
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.DependencyContainers
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+
using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
diff --git a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/HttpContextDIC.cs b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/HttpContextDIC.cs
index 8659df7..2650cdf 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/HttpContextDIC.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/HttpContextDIC.cs
@@ -1,6 +1,6 @@
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.DependencyContainers
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+
using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
diff --git a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/LoggerProviderDIC.cs b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/LoggerProviderDIC.cs
new file mode 100644
index 0000000..a851246
--- /dev/null
+++ b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/LoggerProviderDIC.cs
@@ -0,0 +1,26 @@
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.DependencyContainers
+{
+ using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services;
+ using Microsoft.AspNetCore.Hosting;
+ using Microsoft.Extensions.DependencyInjection;
+ using Microsoft.Extensions.DependencyInjection.Extensions;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using System.Threading.Tasks;
+ public static class LoggerProviderDIC
+ {
+ public static IServiceCollection AddLoggerProviderServices(this IServiceCollection services)
+ {
+ services.AddSingleton();
+ return services;
+ }
+
+ public static IServiceCollection TryAddLoggerProviderServices(this IServiceCollection services)
+ {
+ services.TryAddSingleton();
+ return services;
+ }
+ }
+}
diff --git a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/MediatRDIC.cs b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/MediatRDIC.cs
index da88401..39d64a9 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/MediatRDIC.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/MediatRDIC.cs
@@ -1,6 +1,5 @@
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.DependencyContainers
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
diff --git a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/PreConfigurationDIC.cs b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/PreConfigurationDIC.cs
new file mode 100644
index 0000000..6309b80
--- /dev/null
+++ b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/PreConfigurationDIC.cs
@@ -0,0 +1,18 @@
+using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.DependencyContainers
+{
+ public class PreConfigurationDIC
+ {
+ public IServiceCollection AddWebPreConfigurations(ref IServiceCollection services)
+ {
+
+ services.AddWebHostingServices();
+ services.AddLoggerProviderServices();
+ services.AddSingleton();
+ services.AddSingleton();
+ return services;
+ }
+ }
+}
diff --git a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/WebHostingDIC.cs b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/WebHostingDIC.cs
index 16aefa1..a9000ef 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/WebHostingDIC.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/DependencyContainers/WebHostingDIC.cs
@@ -1,9 +1,9 @@
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.DependencyContainers
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
+ using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -11,10 +11,18 @@
using System.Threading.Tasks;
public static class WebHostingDIC
{
- public static IServiceCollection AddWebHostingService(this IServiceCollection services)
+ public static IServiceCollection AddWebHostingServices(this IServiceCollection services)
{
+ services.AddSingleton();
services.AddSingleton();
return services;
}
+
+ public static IServiceCollection TryAddWebHostingServices(this IServiceCollection services)
+ {
+ services.TryAddSingleton();
+ services.TryAddSingleton();
+ return services;
+ }
}
}
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportAllDotNetCenterServices.cs b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportAllDotNetCenterServices.cs
index 21ae863..d560007 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportAllDotNetCenterServices.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportAllDotNetCenterServices.cs
@@ -1,4 +1,4 @@
-namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices
{
public interface SupportAllDotNetCenterServices
{
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportAutoMapper.cs b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportAutoMapper.cs
index a082ee6..f2a5714 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportAutoMapper.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportAutoMapper.cs
@@ -1,4 +1,4 @@
-namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices
{
using global::AutoMapper;
using System;
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportConfiguration.cs b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportConfiguration.cs
index a89cab5..24f0fc5 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportConfiguration.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportConfiguration.cs
@@ -1,5 +1,5 @@
using Microsoft.Extensions.Configuration;
-namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices
{
public interface SupportConfiguration
{
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportDateTime.cs b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportDateTime.cs
index 1c5ff32..5037d0b 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportDateTime.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportDateTime.cs
@@ -4,7 +4,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices
{
public interface SupportDateTime
where TAppDateTimeNowService : CompoundableDateTimeNow
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportHttpContextServices.cs b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportHttpContextServices.cs
index 897087e..f6517b1 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportHttpContextServices.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportHttpContextServices.cs
@@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Http;
-namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices
{
public interface SupportHttpContextServices
{
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportLoggerProviders.cs b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportLoggerProviders.cs
new file mode 100644
index 0000000..acb9abb
--- /dev/null
+++ b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportLoggerProviders.cs
@@ -0,0 +1,8 @@
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices
+{
+ using Microsoft.Extensions.Logging;
+ public interface SupportLoggerProviders
+ {
+ public ILoggerFactory Factory { get; }
+ }
+}
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportLoggingServices.cs b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportLoggingServices.cs
index 9a01001..1a1548e 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportLoggingServices.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportLoggingServices.cs
@@ -1,18 +1,9 @@
-namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services;
using DotNetCenter.Beyond.Web.Core.Common;
- using DotNetCenter.Beyond.Web.Core.Controllers;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
public interface SupportLoggingServices
- where TController : ProcessableEntry
+where TController : ProcessableEntry
{
public ILogger Logger { get; }
}
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportMediateR.cs b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportMediateR.cs
index 05948f6..9737f12 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportMediateR.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportMediateR.cs
@@ -1,5 +1,5 @@
using MediatR;
-namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices
{
public interface SupportMediateR
{
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportPreConfiguration.cs b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportPreConfiguration.cs
new file mode 100644
index 0000000..5623229
--- /dev/null
+++ b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportPreConfiguration.cs
@@ -0,0 +1,10 @@
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices
+{
+ using Microsoft.Extensions.Logging;
+ public interface SupportPreConfiguration
+ {
+ public SupportLoggerProviders LoggerProviders { get; }
+ public SupportWebHosting WebHosting { get; }
+ public SupportConfiguration Configuration { get; }
+ }
+}
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportWebHosting.cs b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportWebHosting.cs
index 001e2a8..6086fb2 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportWebHosting.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Interfaces/SupportWebHosting.cs
@@ -5,7 +5,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices
{
///
/// ####
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/AllDotNetCenterServices.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/AllDotNetCenterServices.cs
index 7366436..e7f2b9a 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Services/AllDotNetCenterServices.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/AllDotNetCenterServices.cs
@@ -1,4 +1,4 @@
-using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/AutoMapperService.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/AutoMapperService.cs
index c078e06..5364068 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Services/AutoMapperService.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/AutoMapperService.cs
@@ -5,7 +5,7 @@
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
-using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+
using Microsoft.AspNetCore.Http;
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services
{
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/ConfigurationService.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/ConfigurationService.cs
index 542ae9d..9a22dce 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Services/ConfigurationService.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/ConfigurationService.cs
@@ -1,4 +1,4 @@
-using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using System;
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/DateTimeService.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/DateTimeService.cs
index d8ba23c..ebbdeee 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Services/DateTimeService.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/DateTimeService.cs
@@ -1,4 +1,4 @@
-using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+
using Microsoft.AspNetCore.Http;
using System;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/HttpContextServices.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/HttpContextServices.cs
index 8d7db97..5e6ebe4 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Services/HttpContextServices.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/HttpContextServices.cs
@@ -1,17 +1,10 @@
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services
{
- using Microsoft.Extensions.DependencyInjection;
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
using Microsoft.AspNetCore.Http;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
public class HttpContextServices : SupportHttpContextServices
{
#region Constructor
- public HttpContextServices(IHttpContextAccessor httpContextAccessor)
+ public HttpContextServices(IHttpContextAccessor httpContextAccessor)
=> _httpContextAccessor = httpContextAccessor;
#endregion
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/LoggerProviderService.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/LoggerProviderService.cs
new file mode 100644
index 0000000..f295cfd
--- /dev/null
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/LoggerProviderService.cs
@@ -0,0 +1,25 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
+using DotNetCenter.Beyond.Web.Core.Controllers;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+using DotNetCenter.Beyond.Web.Core.Common;
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services
+{
+ public class LoggerProviderService
+ : SupportLoggerProviders
+ {
+ #region Constructor
+ public LoggerProviderService(ILoggerFactory factory)
+ => _factory = factory;
+ #endregion
+
+ public ILoggerFactory Factory => _factory;
+ private readonly ILoggerFactory _factory;
+ }
+}
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/LoggingService.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/LoggingService.cs
index 9ba9166..10adefa 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Services/LoggingService.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/LoggingService.cs
@@ -1,5 +1,4 @@
-using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
-using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/MediateRService.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/MediateRService.cs
index 2a7eb24..f7e5ed1 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Services/MediateRService.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/MediateRService.cs
@@ -6,7 +6,7 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
-using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services
{
public class MediateRService
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/PreConfigurationService.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/PreConfigurationService.cs
new file mode 100644
index 0000000..f4b41cc
--- /dev/null
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/PreConfigurationService.cs
@@ -0,0 +1,37 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
+using DotNetCenter.Beyond.Web.Core.Controllers;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+using DotNetCenter.Beyond.Web.Core.Common;
+namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services
+{
+ public class PreConfigurationService
+ : SupportPreConfiguration
+ {
+ #region Constructor
+ public PreConfigurationService(SupportConfiguration configuration,
+ SupportWebHosting webHosting,
+ SupportLoggerProviders loggerProviders)
+ {
+ _configuraion = configuration;
+ _loggerProviders = loggerProviders;
+ _webHosting = webHosting;
+ }
+ #endregion
+
+ public SupportConfiguration Configuration => _configuraion;
+ private readonly SupportConfiguration _configuraion;
+
+ public SupportLoggerProviders LoggerProviders => _loggerProviders;
+ private readonly SupportLoggerProviders _loggerProviders;
+
+ public SupportWebHosting WebHosting => _webHosting;
+ private readonly SupportWebHosting _webHosting;
+ }
+}
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/WebHostingService.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/WebHostingService.cs
index be31288..301585b 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Services/WebHostingService.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/WebHostingService.cs
@@ -1,6 +1,6 @@
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/Web/Core/Source/Common/DIContainerServices/Services/WebHostingServiceWrapper.cs b/src/Web/Core/Source/Common/DIContainerServices/Services/WebHostingServiceWrapper.cs
index 6294fd2..fcfe6be 100644
--- a/src/Web/Core/Source/Common/DIContainerServices/Services/WebHostingServiceWrapper.cs
+++ b/src/Web/Core/Source/Common/DIContainerServices/Services/WebHostingServiceWrapper.cs
@@ -1,6 +1,5 @@
namespace DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Services
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/Web/Core/Source/Extensions/CommonServiceCollectionExtension.cs b/src/Web/Core/Source/Extensions/CommonServiceCollectionExtension.cs
index fdd1e63..ae10e85 100644
--- a/src/Web/Core/Source/Extensions/CommonServiceCollectionExtension.cs
+++ b/src/Web/Core/Source/Extensions/CommonServiceCollectionExtension.cs
@@ -1,6 +1,6 @@
namespace DotNetCenter.Beyond.Web.Core.Extensions
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+ using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
diff --git a/src/Web/Core/Source/Extensions/Hosting/CommonWebHostBuilderExtension.cs b/src/Web/Core/Source/Extensions/Hosting/CommonWebHostBuilderExtension.cs
index 01547bb..cc43dfd 100644
--- a/src/Web/Core/Source/Extensions/Hosting/CommonWebHostBuilderExtension.cs
+++ b/src/Web/Core/Source/Extensions/Hosting/CommonWebHostBuilderExtension.cs
@@ -8,23 +8,25 @@
using System.Net;
using System.Text;
using System.Threading.Tasks;
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
using DotNetCenter.Beyond.Web.Core.Common;
+ using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.DependencyContainers;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Configuration;
+ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
public static class CommonWebHostBuilderExtension
{
- public static IWebHostBuilder CreateDotNetCenterWebHostBuilder(
+ public static IWebHostBuilder CreateDotNetCenterWebHostBuilder(
string envName
, string contentRootPath
, string webHostBuilderBasePath
, string[] args)
- where TStartup : class, IAppStartup
+ where TStartup : class,
+ IAppStartup
{
return new WebHostBuilder()
.UseContentRoot(contentRootPath)
@@ -33,9 +35,13 @@ string envName
.UseDefaultKestrel()
.UseIISIntegration()
.ConfigureDefaultLogging()
+ .ConfigureServices((hostContext) =>
+ {
+ new PreConfigurationDIC().AddWebPreConfigurations(ref hostContext);
+ })
.UseStartup();
}
- public static IWebHostBuilder CreateDotNetCenterWebHostBuilder(
+ public static IWebHostBuilder CreateDotNetCenterWebHostBuilder(
string envName
, string contentRootPath
, string webHostBuilderBasePath
@@ -52,7 +58,7 @@ string envName
, int limitKeepAliveTimeout = 30
, int RequestHeadersTimeout = 30
)
- where TStartup : class , IAppStartup
+ where TStartup : class , IAppStartup
{
return new WebHostBuilder()
.UseContentRoot(contentRootPath)
@@ -72,6 +78,10 @@ string envName
RequestHeadersTimeout)
.UseIISIntegration()
.ConfigureDefaultLogging()
+ .ConfigureServices((hostContext) =>
+ {
+ new PreConfigurationDIC().AddWebPreConfigurations(ref hostContext);
+ })
.UseStartup();
}
}
diff --git a/src/Web/Core/Source/Extensions/Hosting/Kestrel/DefaultKestrelExtension.cs b/src/Web/Core/Source/Extensions/Hosting/Kestrel/DefaultKestrelExtension.cs
index 7347b09..c9fdeef 100644
--- a/src/Web/Core/Source/Extensions/Hosting/Kestrel/DefaultKestrelExtension.cs
+++ b/src/Web/Core/Source/Extensions/Hosting/Kestrel/DefaultKestrelExtension.cs
@@ -6,7 +6,6 @@
using System.Net;
using System.Text;
using System.Threading.Tasks;
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
using DotNetCenter.Beyond.Web.Core.Common;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
@@ -51,7 +50,7 @@ this IWebHostBuilder host
return host;
}
- public static IWebHostBuilder CreateDotNetCenterWebHostBuilder(
+ public static IWebHostBuilder CreateDotNetCenterWebHostBuilder(
string envName
, string contentRootPath
, string webHostBuilderBasePath
@@ -67,8 +66,7 @@ string envName
, int minResponseDataRateGracePeriod = 10
)
where TStartup :
- class
- , IAppStartup
+ class, IAppStartup
{
return new WebHostBuilder()
.UseContentRoot(contentRootPath)
diff --git a/src/Web/Core/Source/Middlewares/DefaultRazorpagesMiddlewareExtension.cs b/src/Web/Core/Source/Middlewares/DefaultRazorpagesMiddlewareExtension.cs
index 96002ce..b58140c 100644
--- a/src/Web/Core/Source/Middlewares/DefaultRazorpagesMiddlewareExtension.cs
+++ b/src/Web/Core/Source/Middlewares/DefaultRazorpagesMiddlewareExtension.cs
@@ -1,6 +1,6 @@
namespace DotNetCenter.Beyond.Web.Core.Middlewares
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+ using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
@@ -9,9 +9,10 @@
using System.Text;
public static class DefaultRazorpagesMiddlewareExtension
{
- public static IApplicationBuilder UseWeb(this IApplicationBuilder app, SupportWebHosting env, ILoggerFactory logger)
+ public static IApplicationBuilder UseWeb(this IApplicationBuilder app, SupportPreConfiguration preConfiguration)
{
- app.UseStopWatchMiddleware(env, logger);
+ var env = preConfiguration.WebHosting;
+ app.UseStopWatchMiddleware(preConfiguration);
app.UseExceptionMiddleware(env);
diff --git a/src/Web/Core/Source/Middlewares/ExceptionMiddleware.cs b/src/Web/Core/Source/Middlewares/ExceptionMiddleware.cs
index 891973d..fb0016f 100644
--- a/src/Web/Core/Source/Middlewares/ExceptionMiddleware.cs
+++ b/src/Web/Core/Source/Middlewares/ExceptionMiddleware.cs
@@ -4,7 +4,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore;
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+ using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices;
public static class ExceptionMiddleware
{
diff --git a/src/Web/Core/Source/Middlewares/StopWatchMiddleware.cs b/src/Web/Core/Source/Middlewares/StopWatchMiddleware.cs
index dc7909f..8c76c5d 100644
--- a/src/Web/Core/Source/Middlewares/StopWatchMiddleware.cs
+++ b/src/Web/Core/Source/Middlewares/StopWatchMiddleware.cs
@@ -1,6 +1,6 @@
namespace DotNetCenter.Beyond.Web.Core.Middlewares
{
- using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices.Interfaces;
+ using DotNetCenter.Beyond.Web.Core.Common.DIContainerServices;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
@@ -12,9 +12,10 @@ public static class StopWatchMiddleware
{
public static IApplicationBuilder UseStopWatchMiddleware(
this IApplicationBuilder app,
- SupportWebHosting env,
- ILoggerFactory loggerFactory)
+ SupportPreConfiguration preConfiguration)
{
+ var env = preConfiguration.WebHosting;
+ var loggerFactory = preConfiguration.LoggerProviders.Factory;
if (env.Service.IsDevelopment())
app.Use(async (context, next) =>
{
diff --git a/src/Web/Core/Source/Presenters/BasePresenter.cs b/src/Web/Core/Source/Presenters/BasePresenter.cs
index 28442bb..1fad129 100644
--- a/src/Web/Core/Source/Presenters/BasePresenter.cs
+++ b/src/Web/Core/Source/Presenters/BasePresenter.cs
@@ -9,10 +9,10 @@ public abstract class BasePresenter : ConfigurablePresenter
{
public BasePresenter(IHttpContextAccessor context) : base(context)
=> HttpContextAccessor = context;
- public IMapper Mapper => _mapper ??= HttpContextAccessor.HttpContext.RequestServices.GetService();
- protected IMapper _mapper;
- private IMediator _mediator;
+ protected IMapper Mapper => _mapper ??= HttpContextAccessor.HttpContext.RequestServices.GetService();
+ private IMapper _mapper;
protected IMediator Mediator => _mediator ??= HttpContextAccessor.HttpContext.RequestServices.GetService();
+ private IMediator _mediator;
}
}
diff --git a/src/Web/Core/Source/ViewComponents/BaseViewComponent.cs b/src/Web/Core/Source/ViewComponents/BaseViewComponent.cs
index 7f623da..df9efc1 100644
--- a/src/Web/Core/Source/ViewComponents/BaseViewComponent.cs
+++ b/src/Web/Core/Source/ViewComponents/BaseViewComponent.cs
@@ -5,9 +5,9 @@
using Microsoft.Extensions.DependencyInjection;
public abstract class BaseViewComponent : ConfigurableViewComponent
{
- private IMediator _mediator;
- private IMapper _mapper;
protected IMediator Mediator => _mediator ??= HttpContext.RequestServices.GetService();
+ private IMediator _mediator;
protected IMapper Mapper => _mapper ??= HttpContext.RequestServices.GetService();
+ private IMapper _mapper;
}
}
diff --git a/src/Web/Identity/Core/Source/Common/Interfaces/CurrentUserService.cs b/src/Web/Identity/Core/Source/Common/Interfaces/CurrentUserService.cs
deleted file mode 100644
index 4cf2e97..0000000
--- a/src/Web/Identity/Core/Source/Common/Interfaces/CurrentUserService.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core
-{
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
- using System;
- public interface CurrentUserService
- {
- bool TrySetUsername();
- bool TrySetUserId();
- Guid UserId { get; }
- string Username { get; }
- public bool IsUserAuthenticated { get; }
- }
-}
diff --git a/src/Web/Identity/Core/Source/Common/Interfaces/IdentityService.cs b/src/Web/Identity/Core/Source/Common/Interfaces/IdentityService.cs
deleted file mode 100644
index 31b1cd8..0000000
--- a/src/Web/Identity/Core/Source/Common/Interfaces/IdentityService.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core
-{
- using System;
- using System.Threading.Tasks;
- using DotNetCenter.Core.ErrorHandlers;
- public interface IdentityService
- {
- Task GetUsernameAsync(Guid userId);
- Task<(ResultContainer Result, Guid UserId)> CreateUserAsync(string userName, string password);
- Task DeleteUserAsync(Guid userId);
- }
-}
diff --git a/src/Web/Identity/Core/Source/Common/Interfaces/TrackableEntity.cs b/src/Web/Identity/Core/Source/Common/Interfaces/TrackableEntity.cs
deleted file mode 100644
index 2b9764e..0000000
--- a/src/Web/Identity/Core/Source/Common/Interfaces/TrackableEntity.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core
-{
- public interface TrackableEntity
- {
- }
-}
diff --git a/src/Web/Identity/Core/Source/Common/Models/AppRole.cs b/src/Web/Identity/Core/Source/Common/Models/AppRole.cs
deleted file mode 100644
index 73fb68d..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/AppRole.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- using Microsoft.AspNetCore.Identity;
- using System;
- public class AppRole
- : IdentityRole
- , IAppRole
- {
- public AppRole() { }
- public AppRole(string name)
- => Name = name;
- public AppRole(string name, string _description)
- {
- Name = name;
- Description = _description;
- }
- public string Description { get; protected set; }
- public string Tag { get; protected set;}
-
- #region Audit
- public Guid LastModifiedBy => _lastModifierId;
- private Guid _lastModifierId;
-
- public DateTime? LastModifiedDateTime => throw new NotImplementedException();
- private DateTime? _lastModifiedDateTime;
-
- public Guid CreatedBy => _creatorId;
- private readonly Guid _creatorId;
-
- public DateTime CreatedDateTime => throw new NotImplementedException();
-
- private readonly DateTime _createdDateTime;
-
- public void RegisterModifiedInformation(Guid modifierId, DateTime modifiedDateTime)
- {
- _lastModifierId = modifierId;
- _lastModifiedDateTime = modifiedDateTime;
- }
- #endregion
- }
-}
diff --git a/src/Web/Identity/Core/Source/Common/Models/AppRoleClaim.cs b/src/Web/Identity/Core/Source/Common/Models/AppRoleClaim.cs
deleted file mode 100644
index 9a6a4bb..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/AppRoleClaim.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- using Microsoft.AspNetCore.Identity;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- public class AppRoleClaim
- : IdentityRoleClaim
- , IAppRoleClaim
- {
- }
-}
diff --git a/src/Web/Identity/Core/Source/Common/Models/AppUser.cs b/src/Web/Identity/Core/Source/Common/Models/AppUser.cs
deleted file mode 100644
index 75e6e1a..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/AppUser.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- using Microsoft.AspNetCore.Identity;
- using System;
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
-
- public class AppUser : IdentityUser
- , IAppUser
- {
- public AppUser(Guid id, DateTime createdDateTime)
- {
- _id = id;
- _createdDateTime = createdDateTime;
- }
-
- public virtual bool ValidateUsername()
- {
- if (!string.IsNullOrEmpty(_username))
- return true;
-
- if (ValidateIdentityUser())
- return true;
-
- return !string.IsNullOrEmpty(_identityUser.UserName);
- }
- public virtual bool ValidateEmail()
- {
- if (!string.IsNullOrEmpty(_email))
- return true;
-
- if (ValidateIdentityUser())
- return true;
-
- return !string.IsNullOrEmpty(_identityUser.Email);
- }
-
- public virtual bool ValidateIdentityUser()
- {
- return TrySetIdentityUser();
- }
-
- [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
- public new Guid Id => _id;
- private readonly Guid _id;
-
- public string PlainPassword => _plainPassword;
- private readonly string _plainPassword;
- public string ProfilePictureAddress { get; protected set; } = "/user/images/profile/default.png";
- public string FirstName { get; protected set; }
- public string LastName { get; protected set; }
- public string DisplayName { get; protected set; }
- public string AccountType { get; protected set; }
- public DateTime DateRegistered { get; protected set; }
- public string Tag { get; protected set; }
-
- #region Audit
- public Guid LastModifiedBy => _lastModifierId;
- private Guid _lastModifierId;
-
- public DateTime? LastModifiedDateTime => throw new NotImplementedException();
- private DateTime? _lastModifiedDateTime;
-
- public Guid CreatedBy => _creatorId;
- private readonly Guid _creatorId;
-
- public DateTime CreatedDateTime => _createdDateTime;
- private readonly DateTime _createdDateTime;
-
- public string Username => _username;
- private readonly string _username;
-
- public IdentityUser IdentityUser => _identityUser;
- private IdentityUser _identityUser;
- public string Email => _email;
- private readonly string _email;
-
- public void RegisterModifiedInformation(Guid modifierId, DateTime modifiedDateTime)
- {
- _lastModifierId = modifierId;
- _lastModifiedDateTime = modifiedDateTime;
- }
- #endregion
- #region GetIdentityUser()
- public virtual bool TrySetIdentityUser()
- {
- if (_identityUser is not null)
- return true;
-
- var idUser = new IdentityUser(userName: this.Username)
- {
- Id = this.Id.ToString(),
- AccessFailedCount = this.AccessFailedCount,
- TwoFactorEnabled = this.TwoFactorEnabled,
- SecurityStamp = this.SecurityStamp,
- PhoneNumberConfirmed = this.PhoneNumberConfirmed,
- PhoneNumber = this.PhoneNumber,
- PasswordHash = this.PasswordHash,
- UserName = this.Username,
- NormalizedEmail = this.NormalizedEmail,
- NormalizedUserName = this.NormalizedUserName,
- ConcurrencyStamp = this.ConcurrencyStamp,
- Email = this.Email,
- EmailConfirmed = this.EmailConfirmed,
- LockoutEnabled = this.LockoutEnabled,
- LockoutEnd = this.LockoutEnd
- };
- try
- {
- _identityUser = idUser;
- }
- catch (InvalidCastException ex)
- {
- return false;
- }
- catch (Exception ex)
- {
- return false;
- }
-
- if (_identityUser is null)
- return false;
- if (string.IsNullOrEmpty(_identityUser.UserName))
- return false;
-
- return true;
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/Web/Identity/Core/Source/Common/Models/AppUserClaim.cs b/src/Web/Identity/Core/Source/Common/Models/AppUserClaim.cs
deleted file mode 100644
index 479bc92..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/AppUserClaim.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- using System;
- using Microsoft.AspNetCore.Identity;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- public class AppUserClaim
- : IdentityUserClaim
- , IAppUserClaim
- {
- }
-}
diff --git a/src/Web/Identity/Core/Source/Common/Models/AppUserRole.cs b/src/Web/Identity/Core/Source/Common/Models/AppUserRole.cs
deleted file mode 100644
index bcfb248..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/AppUserRole.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- using Microsoft.AspNetCore.Identity;
- using System;
-
- public class AppUserRole
- : IdentityUserRole
- , IAppUserRole
- {
- public AppUserRole(int id, DateTime createdDateTime)
- {
- _id = id;
- _createdDateTime = createdDateTime;
- }
- public int Id { get => _id; }
- private readonly int _id;
-
- #region Audit
- public Guid LastModifiedBy => _lastModifierId;
- private Guid _lastModifierId;
-
- public DateTime? LastModifiedDateTime => throw new NotImplementedException();
- private DateTime? _lastModifiedDateTime;
-
- public Guid CreatedBy => _creatorId;
- private readonly Guid _creatorId;
-
- public DateTime CreatedDateTime => throw new NotImplementedException();
-
- private readonly DateTime _createdDateTime;
-
- public void RegisterModifiedInformation(Guid modifierId, DateTime modifiedDateTime)
- {
- _lastModifierId = modifierId;
- _lastModifiedDateTime = modifiedDateTime;
- }
- #endregion
- }
-}
diff --git a/src/Web/Identity/Core/Source/Common/Models/IAppRole.cs b/src/Web/Identity/Core/Source/Common/Models/IAppRole.cs
deleted file mode 100644
index 238ada9..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/IAppRole.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using DotNetCenter.Core.Entities;
-using System;
-
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- public interface IAppRole: AuditableEntity
- {
- public string Name { get; }
- public string Description { get; }
- public string Tag { get; }
- }
-}
\ No newline at end of file
diff --git a/src/Web/Identity/Core/Source/Common/Models/IAppRoleClaim.cs b/src/Web/Identity/Core/Source/Common/Models/IAppRoleClaim.cs
deleted file mode 100644
index 22cdf75..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/IAppRoleClaim.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- public interface IAppRoleClaim
- {
- }
-}
\ No newline at end of file
diff --git a/src/Web/Identity/Core/Source/Common/Models/IAppUser.cs b/src/Web/Identity/Core/Source/Common/Models/IAppUser.cs
deleted file mode 100644
index 4081ce8..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/IAppUser.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- using DotNetCenter.Core.Entities;
- using Microsoft.AspNetCore.Identity;
- using System;
- using System.Collections.Generic;
-
- public interface IAppUser : AuditableEntity
- , TrackableEntity
- {
- public string Tag { get; }
- public string ProfilePictureAddress { get; }
- public string FirstName { get; }
- public string LastName { get; }
- public string Username { get; }
- public string Email { get; }
- public string DisplayName { get; }
- public string AccountType { get; }
- public System.DateTime DateRegistered { get; }
- public bool TrySetIdentityUser();
- public bool ValidateIdentityUser();
- }
-}
\ No newline at end of file
diff --git a/src/Web/Identity/Core/Source/Common/Models/IAppUserClaim.cs b/src/Web/Identity/Core/Source/Common/Models/IAppUserClaim.cs
deleted file mode 100644
index 9bb1104..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/IAppUserClaim.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- public interface IAppUserClaim
- {
- }
-}
\ No newline at end of file
diff --git a/src/Web/Identity/Core/Source/Common/Models/IAppUserLogin.cs b/src/Web/Identity/Core/Source/Common/Models/IAppUserLogin.cs
deleted file mode 100644
index 5fe756a..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/IAppUserLogin.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- public interface IAppUserLogin
- {
- }
-}
\ No newline at end of file
diff --git a/src/Web/Identity/Core/Source/Common/Models/IAppUserRole.cs b/src/Web/Identity/Core/Source/Common/Models/IAppUserRole.cs
deleted file mode 100644
index 9af360a..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/IAppUserRole.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using DotNetCenter.Core.Entities;
-using System;
-
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- public interface IAppUserRole : AuditableEntity
- {
- }
-}
\ No newline at end of file
diff --git a/src/Web/Identity/Core/Source/Common/Models/IAppUserToken.cs b/src/Web/Identity/Core/Source/Common/Models/IAppUserToken.cs
deleted file mode 100644
index 0783fb7..0000000
--- a/src/Web/Identity/Core/Source/Common/Models/IAppUserToken.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
-{
- public interface IAppUserToken
- {
- }
-}
\ No newline at end of file
diff --git a/src/Web/Identity/Core/Source/DependencyResolution/ManagerServicesDIC.cs b/src/Web/Identity/Core/Source/DependencyResolution/ManagerServicesDIC.cs
deleted file mode 100644
index ee6f32b..0000000
--- a/src/Web/Identity/Core/Source/DependencyResolution/ManagerServicesDIC.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using DotNetCenter.Beyond.Web.Identity.Core.Managers;
-using DotNetCenter.Beyond.Web.Identity.Core.Models;
-using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DotNetCenter.Beyond.Web.Identity.Core.DependencyResolution
-{
- public static class ManagerServicesDIC
- {
- public static IServiceCollection AddManagerServices(this IServiceCollection services)
- where TUserManager : class, UserManagerService
- where TSignInManager : class, SignInManagerService
- {
- services.AddSingleton, TUserManager>();
- services.AddSingleton, TSignInManager>();
- return services;
- }
- }
-}
diff --git a/src/Web/Identity/Core/Source/DotNetCenter.Beyond.Web.Identity.Core.csproj b/src/Web/Identity/Core/Source/DotNetCenter.Beyond.Web.Identity.Core.csproj
index 5875c90..7a5218e 100644
--- a/src/Web/Identity/Core/Source/DotNetCenter.Beyond.Web.Identity.Core.csproj
+++ b/src/Web/Identity/Core/Source/DotNetCenter.Beyond.Web.Identity.Core.csproj
@@ -64,7 +64,6 @@
-
@@ -77,4 +76,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppRoleClaimConfig.cs b/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppRoleClaimConfig.cs
deleted file mode 100644
index aa1b593..0000000
--- a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppRoleClaimConfig.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.Common.Model.Configurations
-{
- using Microsoft.EntityFrameworkCore;
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- using System;
- public abstract class AppRoleClaimConfig
- : IEntityTypeConfiguration
- where TEntity : AppRoleClaim
- {
- public virtual void Configure(EntityTypeBuilder builder)
- {
- builder.HasKey(o => o.Id);
-
- builder
- .Property(c => c.Id)
- .HasDefaultValueSql("NEWID()");
- }
- }
-}
diff --git a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppRoleConfig.cs b/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppRoleConfig.cs
deleted file mode 100644
index c18a562..0000000
--- a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppRoleConfig.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.Common.Model.Configurations
-{
- using Microsoft.EntityFrameworkCore;
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- using System;
- public abstract class AppRoleConfig
- : IEntityTypeConfiguration
- where TEntity : AppRole
- {
- public virtual void Configure(EntityTypeBuilder builder)
- {
- builder.HasKey(o => o.Id);
-
- builder
- .Property(c => c.Id)
- .HasDefaultValueSql("NEWID()");
- }
- }
-}
diff --git a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserClaimConfig.cs b/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserClaimConfig.cs
deleted file mode 100644
index 8f158d3..0000000
--- a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserClaimConfig.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.Common.Model.Configurations
-{
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- using System;
- public abstract class AppUserClaimConfig
- : IEntityTypeConfiguration where TEntity
- : AppUserClaim
- {
- public virtual void Configure(EntityTypeBuilder builder)
- {
- builder.HasKey(o => o.Id);
-
- builder
- .Property(c => c.Id)
- .HasDefaultValueSql("NEWID()");
- }
- }
-}
diff --git a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserConfig.cs b/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserConfig.cs
deleted file mode 100644
index 6bb4040..0000000
--- a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserConfig.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.Common.Model.Configurations
-{
- using Microsoft.EntityFrameworkCore;
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- using System;
-
- public abstract class AppUserConfig
- : IEntityTypeConfiguration
- where TEntity : AppUser
- {
- public virtual void Configure(EntityTypeBuilder builder)
- {
-
-
- builder.Property(c => c.Id)
- .HasDefaultValueSql("NEWID()")
- .IsRequired();
-
- builder
- .Property(p => p.DisplayName)
- .HasComputedColumnSql("[LastName] + ', ' + [FirstName]");
-
- builder
- .Property(o => o.DateRegistered)
- .IsRequired();
- }
- }
-}
diff --git a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserLoginConfig.cs b/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserLoginConfig.cs
deleted file mode 100644
index 933f893..0000000
--- a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserLoginConfig.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.Common.Model.Configurations
-{
- using Microsoft.EntityFrameworkCore;
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- using System;
- public abstract class AppUserLoginConfig
- : IEntityTypeConfiguration
- where TEntity : AppUserLogin
- {
- public virtual void Configure(EntityTypeBuilder builder) { }
- }
-}
diff --git a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserRoleConfig.cs b/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserRoleConfig.cs
deleted file mode 100644
index dab16ca..0000000
--- a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserRoleConfig.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.Common.Model.Configurations
-{
- using Microsoft.EntityFrameworkCore;
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- using System;
- public abstract class AppUserRoleConfig
- : IEntityTypeConfiguration
- where TEntity : AppUserRole
- {
- public virtual void Configure(EntityTypeBuilder builder)
- {
- builder.HasKey(o => o.Id);
-
- builder
- .Property(c => c.Id)
- .HasDefaultValueSql("NEWID()");
- }
- }
-}
diff --git a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserTokenConfig.cs b/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserTokenConfig.cs
deleted file mode 100644
index be7aee0..0000000
--- a/src/Web/Identity/Infrastructure/SqlServer/Source/Common/Model/Configurations/AppUserTokenConfig.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.Common.Model.Configurations
-{
- using Microsoft.EntityFrameworkCore;
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- using System;
- public abstract class ApplicationUserTokenConfig
- : IEntityTypeConfiguration
- where TEntity : AppUserToken
- {
- public virtual void Configure(EntityTypeBuilder builder)
- {
- }
- }
-}
diff --git a/src/Web/Identity/Infrastructure/SqlServer/Source/DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.csproj b/src/Web/Identity/Infrastructure/SqlServer/Source/DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.csproj
index 7b66dd5..9923b14 100644
--- a/src/Web/Identity/Infrastructure/SqlServer/Source/DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.csproj
+++ b/src/Web/Identity/Infrastructure/SqlServer/Source/DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.csproj
@@ -73,5 +73,10 @@
+
+
+
+
+
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/BasePersistentObject.cs b/src/Web/Identity/ObjRelMapping/Source/Common/BasePersistentObject.cs
new file mode 100644
index 0000000..f2dee87
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/BasePersistentObject.cs
@@ -0,0 +1,21 @@
+using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
+using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Configuration;
+using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Sys = System;
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common
+{
+ public abstract class BasePersistentObject : BaseDataAccessObject, PersistableObject
+ where TAppUser : IIdentityUser
+ where TKey : struct, IEquatable
+ {
+ public override TKey Id { get => base.Id; set => base.Id = value; }
+ public virtual int? ModifiedBy { get; set; }
+ public virtual Sys.DateTime? ModifiedDateTime { get; set; }
+ public virtual int CreatedBy { get; set; }
+ public virtual Sys.DateTime CreatedDateTime { get; set; }
+
+ }
+}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppRoleClaimConfig.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppRoleClaimConfig.cs
new file mode 100644
index 0000000..e429072
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppRoleClaimConfig.cs
@@ -0,0 +1,34 @@
+//namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Configurations
+//{
+// using Microsoft.EntityFrameworkCore;
+// using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+// using Microsoft.EntityFrameworkCore.Metadata.Builders;
+// using System;
+// using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+// using DotNetCenter.Beyond.ObjRelMapping.Infrastructure.Configuration;
+// using DotNetCenter.Core;
+
+// public abstract class AppRoleClaimConfig
+// : BaseEntityConfiguration
+// where TEntity : class, IRoleClaim, Entity, new()
+// {
+// public AppRoleClaimConfig(bool configureKey = true)
+// :base(configureKey)
+// {
+
+// }
+// public AppRoleClaimConfig(string tableName, string schemaName, bool includeAuditColumns = true)
+// : base(tableName, schemaName, includeAuditColumns)
+// {
+
+// }
+// public AppRoleClaimConfig(bool configureKey = true)
+// : base(configureKey)
+// {
+// }
+// public override void Configure(EntityTypeBuilder builder)
+// {
+// base.Configure(builder);
+// }
+// }
+//}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppRoleConfig.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppRoleConfig.cs
new file mode 100644
index 0000000..a60b757
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppRoleConfig.cs
@@ -0,0 +1,20 @@
+//namespace DotNetCenter.Beyond.Web.Identity.Infrastructure.SqlServer.Common.Model
+//{
+// using Microsoft.EntityFrameworkCore;
+// using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+// using Microsoft.EntityFrameworkCore.Metadata.Builders;
+// using System;
+// public abstract class AppRoleConfig
+// : IEntityTypeConfiguration
+// where TEntity : AppRole
+// {
+// public virtual void Configure(EntityTypeBuilder builder)
+// {
+// builder.HasKey(o => o.Id);
+
+// builder
+// .Property(c => c.Id)
+// .HasDefaultValueSql("NEWID()");
+// }
+// }
+//}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserClaimConfig.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserClaimConfig.cs
new file mode 100644
index 0000000..7e1dda9
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserClaimConfig.cs
@@ -0,0 +1,19 @@
+//namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+//{
+// using Microsoft.EntityFrameworkCore;
+// using Microsoft.EntityFrameworkCore.Metadata.Builders;
+// using System;
+// public abstract class AppUserClaimConfig
+// : IEntityTypeConfiguration where TEntity
+// : AppUserClaim
+// {
+// public virtual void Configure(EntityTypeBuilder builder)
+// {
+// builder.HasKey(o => o.Id);
+
+// builder
+// .Property(c => c.Id)
+// .HasDefaultValueSql("NEWID()");
+// }
+// }
+//}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserConfig.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserConfig.cs
new file mode 100644
index 0000000..7a9932d
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserConfig.cs
@@ -0,0 +1,51 @@
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ using Microsoft.EntityFrameworkCore;
+ using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+ using Microsoft.EntityFrameworkCore.Metadata.Builders;
+ using System;
+
+ public abstract class AppUserConfig
+ : IEntityTypeConfiguration
+ where TEntity : AppUser
+ {
+ ///
+ /// Schema must configred in ef apps that use multi context with different schamas,
+ /// also all configurtins of schemas must configured on all context that used eachother entity
+ ///
+ ///
+ ///
+ ///
+ public AppUserConfig(string tableName, string schemaName, bool includeAuditColumns = true)
+ {
+ _tableName = tableName;
+ _schemaName = schemaName;
+ _includeAuditColumns = includeAuditColumns;
+ }
+ public virtual string TableName => _tableName;
+ private readonly string _tableName;
+ public virtual string SchemaName => _schemaName;
+ private readonly string _schemaName;
+ public virtual bool IncludeAuditColumns => _includeAuditColumns;
+ private readonly bool _includeAuditColumns;
+ public virtual void Configure(EntityTypeBuilder builder)
+ {
+ if (string.IsNullOrEmpty(SchemaName))
+ builder.ToTable(TableName);
+ else
+ builder.ToTable(TableName, SchemaName);
+
+
+ builder
+ .Property(o => o.Id)
+ .UseIdentityColumn(seed: 1, increment: 1)
+ .ValueGeneratedOnAdd()
+ .IsRequired();
+
+
+ builder
+ .Property(p => p.DisplayName)
+ .HasComputedColumnSql("[LastName] + ', ' + [FirstName]");
+ }
+ }
+}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserLoginConfig.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserLoginConfig.cs
new file mode 100644
index 0000000..5ba551c
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserLoginConfig.cs
@@ -0,0 +1,13 @@
+//namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+//{
+// using Microsoft.EntityFrameworkCore;
+// using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+// using Microsoft.EntityFrameworkCore.Metadata.Builders;
+// using System;
+// public abstract class AppUserLoginConfig
+// : IEntityTypeConfiguration
+// where TEntity : AppUserLogin
+// {
+// public virtual void Configure(EntityTypeBuilder builder) { }
+// }
+//}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserRoleConfig.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserRoleConfig.cs
new file mode 100644
index 0000000..a42797d
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserRoleConfig.cs
@@ -0,0 +1,27 @@
+//namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+//{
+// using Microsoft.EntityFrameworkCore;
+// using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+// using Microsoft.EntityFrameworkCore.Metadata.Builders;
+// using System;
+// using DotNetCenter.Beyond.ObjRelMapping.Infrastructure.Configuration;
+
+// public abstract class AppUserRoleConfig
+// : BaseEntityConfiguration
+// where TEntity : class, IRoleClaim, new()
+// {
+// public AppUserRoleConfig(string tableName, string schemaName, bool includeAuditColumns = true)
+// : base(tableName, schemaName, includeAuditColumns)
+// {
+
+// }
+// public AppUserRoleConfig(bool includeAuditColumns = true)
+// : base(includeAuditColumns)
+// {
+// }
+// public override void Configure(EntityTypeBuilder builder)
+// {
+// base.Configure(builder);
+// }
+// }
+//}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserTokenConfig.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserTokenConfig.cs
new file mode 100644
index 0000000..d61f631
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Configurations/AppUserTokenConfig.cs
@@ -0,0 +1,15 @@
+//namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+//{
+// using Microsoft.EntityFrameworkCore;
+// using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+// using Microsoft.EntityFrameworkCore.Metadata.Builders;
+// using System;
+// public abstract class ApplicationUserTokenConfig
+// : IEntityTypeConfiguration
+// where TEntity : AppUserToken
+// {
+// public virtual void Configure(EntityTypeBuilder builder)
+// {
+// }
+// }
+//}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppRole.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppRole.cs
new file mode 100644
index 0000000..181ff5a
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppRole.cs
@@ -0,0 +1,26 @@
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ using Microsoft.AspNetCore.Identity;
+ using System;
+ public class AppRole
+ : IdentityRole
+ , IAppRole
+ {
+ public AppRole() { }
+ public AppRole(string name)
+ => Name = name;
+ public AppRole(string name, string _description)
+ {
+ Name = name;
+ Description = _description;
+ }
+ public string Description { get; set; }
+ public string Tag { get; set;}
+ #region Audit
+ public virtual int? ModifiedBy { get; set; }
+ public virtual DateTime? ModifiedDateTime { get; set; }
+ public virtual int CreatedBy { get; set; }
+ public virtual DateTime CreatedDateTime { get; set; }
+ #endregion
+ }
+}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppRoleClaim.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppRoleClaim.cs
new file mode 100644
index 0000000..0125e76
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppRoleClaim.cs
@@ -0,0 +1,19 @@
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ using Microsoft.AspNetCore.Identity;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using System.Threading.Tasks;
+ public class AppRoleClaim
+ : IdentityRoleClaim
+ , IAppRoleClaim
+ {
+ public override int Id { get => base.Id; set => base.Id = value; }
+ public virtual int? ModifiedBy { get; set; }
+ public virtual DateTime? ModifiedDateTime { get; set; }
+ public virtual int CreatedBy { get; set; }
+ public virtual DateTime CreatedDateTime { get; set; }
+ }
+}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUser.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUser.cs
new file mode 100644
index 0000000..84084ca
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUser.cs
@@ -0,0 +1,15 @@
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ using Microsoft.AspNetCore.Identity;
+ using System;
+ public class AppUser : IdentityUser, IIdentityUser
+ {
+ public override int Id { get => base.Id; set => base.Id = value; }
+ public string Tag { get; set; }
+ public string DisplayName { get; set; }
+ public virtual Guid? ModifiedBy { get; set; }
+ public virtual DateTime? ModifiedDateTime { get; set; }
+ public virtual Guid CreatedBy { get; set; }
+ public virtual DateTime CreatedDateTime { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserClaim.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserClaim.cs
new file mode 100644
index 0000000..600528a
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserClaim.cs
@@ -0,0 +1,19 @@
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ using System;
+ using Microsoft.AspNetCore.Identity;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using System.Threading.Tasks;
+ public class AppUserClaim
+ : IdentityUserClaim
+ , IAppUserClaim
+ {
+ public override int Id { get => base.Id; set => base.Id = value; }
+ public virtual int? ModifiedBy { get; set; }
+ public virtual DateTime? ModifiedDateTime { get; set; }
+ public virtual int CreatedBy { get; set; }
+ public virtual DateTime CreatedDateTime { get; set; }
+ }
+}
diff --git a/src/Web/Identity/Core/Source/Common/Models/AppUserLogin.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserLogin.cs
similarity index 54%
rename from src/Web/Identity/Core/Source/Common/Models/AppUserLogin.cs
rename to src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserLogin.cs
index dde99f2..1077695 100644
--- a/src/Web/Identity/Core/Source/Common/Models/AppUserLogin.cs
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserLogin.cs
@@ -1,10 +1,10 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
{
using Microsoft.AspNetCore.Identity;
using System;
public class AppUserLogin
- : IdentityUserLogin
+ : IdentityUserLogin
, IAppUserLogin
{
}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserRole.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserRole.cs
new file mode 100644
index 0000000..5d3c240
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserRole.cs
@@ -0,0 +1,11 @@
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ using Microsoft.AspNetCore.Identity;
+ using System;
+
+ public class AppUserRole
+ : IdentityUserRole
+ , IRoleClaim
+ {
+ }
+}
diff --git a/src/Web/Identity/Core/Source/Common/Models/AppUserToken.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserToken.cs
similarity index 54%
rename from src/Web/Identity/Core/Source/Common/Models/AppUserToken.cs
rename to src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserToken.cs
index c43065b..6b50c0f 100644
--- a/src/Web/Identity/Core/Source/Common/Models/AppUserToken.cs
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/AppUserToken.cs
@@ -1,9 +1,9 @@
-namespace DotNetCenter.Beyond.Web.Identity.Core.Models
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
{
using Microsoft.AspNetCore.Identity;
using System;
public class AppUserToken
- : IdentityUserToken
+ : IdentityUserToken
, IAppUserToken
{
}
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppRole.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppRole.cs
new file mode 100644
index 0000000..258c42a
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppRole.cs
@@ -0,0 +1,13 @@
+using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
+using DotNetCenter.Core.Entities;
+using System;
+
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ public interface IAppRole: PersistableObject
+ {
+ public string Name { get; }
+ public string Description { get; }
+ public string Tag { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppRoleClaim.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppRoleClaim.cs
new file mode 100644
index 0000000..92334e8
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppRoleClaim.cs
@@ -0,0 +1,8 @@
+using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
+
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ public interface IAppRoleClaim : PersistableObject
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserClaim.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserClaim.cs
new file mode 100644
index 0000000..4ee45bd
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserClaim.cs
@@ -0,0 +1,8 @@
+using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
+
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ public interface IAppUserClaim : PersistableObject
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserLogin.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserLogin.cs
new file mode 100644
index 0000000..08feb80
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserLogin.cs
@@ -0,0 +1,6 @@
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ public interface IAppUserLogin
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserRole.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserRole.cs
new file mode 100644
index 0000000..405307d
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserRole.cs
@@ -0,0 +1,11 @@
+using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
+using DotNetCenter.Core;
+using DotNetCenter.Core.Entities;
+using System;
+
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ public interface IRoleClaim
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserToken.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserToken.cs
new file mode 100644
index 0000000..22780cc
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IAppUserToken.cs
@@ -0,0 +1,6 @@
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ public interface IAppUserToken
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Web/Identity/ObjRelMapping/Source/Common/Models/IIdentityUser.cs b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IIdentityUser.cs
new file mode 100644
index 0000000..57dd3ba
--- /dev/null
+++ b/src/Web/Identity/ObjRelMapping/Source/Common/Models/IIdentityUser.cs
@@ -0,0 +1,18 @@
+
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models
+{
+ using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
+ using DotNetCenter.Core.Entities;
+ using Microsoft.AspNetCore.Identity;
+ using System;
+ using System.Collections.Generic;
+
+ public interface IIdentityUser: IAppUser
+ {
+ public string Tag { get; }
+ public string UserName { get; }
+ public string Email { get; }
+ public string DisplayName { get; }
+ //public bool ValidateIdentityUser();
+ }
+}
\ No newline at end of file
diff --git a/src/Web/Identity/ObjRelMapping/Source/DbContextServices/Auditor.cs b/src/Web/Identity/ObjRelMapping/Source/DbContextServices/Auditor.cs
deleted file mode 100644
index 6790d8e..0000000
--- a/src/Web/Identity/ObjRelMapping/Source/DbContextServices/Auditor.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DbContextServices
-{
- using DotNetCenter.Beyond.ObjRelMapping.Core.Auditing;
- using DotNetCenter.Beyond.Web.Identity.Core;
- using DotNetCenter.Core.Entities;
- using DotNetCenter.DateTime.Common;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.ChangeTracking;
- using System;
-
- public class Auditor : Auditable
- {
- private readonly CurrentUserService _currentUserService;
- private readonly CompoundableDateTimeNow _dateTime;
- public Auditor(CurrentUserService currentUserService, CompoundableDateTimeNow dateTime)
- {
- _currentUserService = currentUserService;
- _dateTime = dateTime;
- }
- ///
- /// Update Modified Informations to all the Entities in change tracker thats in modified state
- ///
- ///
- public void UpdateModifiedAll(ChangeTracker changeTracker)
- {
- foreach (var entry in changeTracker.Entries>())
- switch (entry.State)
- {
- //case EntityState.Added:
- // entry.Entity.EntityCreated(_currentUserService.UserId, _dateTime.DateTimeNow);
- //break;
- case EntityState.Modified:
- entry.Entity.RegisterModifiedInformation(_currentUserService.UserId, _dateTime.DateTimeNow);
- break;
- }
- }
- }
-}
diff --git a/src/Web/Identity/ObjRelMapping/Source/DbContextServices/BaseIdentityDbContext.cs b/src/Web/Identity/ObjRelMapping/Source/DbContextServices/BaseIdentityDbContext.cs
index 3b61eb0..d62650e 100644
--- a/src/Web/Identity/ObjRelMapping/Source/DbContextServices/BaseIdentityDbContext.cs
+++ b/src/Web/Identity/ObjRelMapping/Source/DbContextServices/BaseIdentityDbContext.cs
@@ -1,28 +1,98 @@
-namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DbContextServices
-{
- using DotNetCenter.Beyond.Web.Identity.Core;
- using DotNetCenter.Beyond.ObjRelMapping.Core.Auditing;
- using Microsoft.AspNetCore.Identity;
- using Microsoft.EntityFrameworkCore;
- using System;
- using System.Threading;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
-
- public abstract class BaseIdentityDbContext
- : IdentityDbContext
- where TContext : IdentityDbContext
- , new()
+//namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DbContextServices
+//{
+// using DotNetCenter.Beyond.Web.Identity.Core;
+// using DotNetCenter.Beyond.ObjRelMapping.Core.Auditing;
+// using Microsoft.AspNetCore.Identity;
+// using Microsoft.EntityFrameworkCore;
+// using System;
+// using System.Threading;
+// using System.Threading.Tasks;
+// using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
+// using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+
+// public abstract class BaseIdentityDbContext
+//
+// : IdentityDbContext
+// where TContext : IdentityDbContext
+// where TAppUser : AppUser
+// where TAppRole : AppRole
+// where TAppUserClaim : AppUserClaim
+// where TUserRole : AppUserRole
+// where TUserLogin : AppUserLogin
+// where TRoleClaim : AppRoleClaim
+// where TUserToken : AppUserToken
+// , new()
+// {
+// public BaseIdentityDbContext() { }
+// public BaseIdentityDbContext(DbContextOptions options, Auditable auditor)
+// : base(options) => _auditor = auditor;
+
+// private readonly Auditable _auditor;
+// public void Audit() => _auditor.UpdateModifiedAll(ChangeTracker);
+
+// public abstract void Save();
+// public abstract Task SaveAsync(CancellationToken cancellationToken);
+// }
+//}
+
+using DotNetCenter.Beyond.Web.Identity.Core;
+using DotNetCenter.Beyond.ObjRelMapping.Core.Auditing;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
+using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+using System.Reflection;
+
+namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DbContextServices
+{
+ public abstract class BaseIndetityDbContext
+ : IdentityDbContext
+ , IdentityDbService
+ where TAppUser : IdentityUser, IIdentityUser, new()
+ where TAppRole : IdentityRole, IAppRole, new()
+ where TIdentityDbContext : BaseIndetityDbContext
{
- public BaseIdentityDbContext() { }
- public BaseIdentityDbContext(DbContextOptions options, Auditable auditor)
- : base(options) => _auditor = auditor;
+
+ public BaseIndetityDbContext() { }
+ public BaseIndetityDbContext(DbContextOptions options, Auditable auditor)
+ : base(options) => _auditor = auditor;
+
+ public virtual string Schema { get; }
+ public abstract Assembly ConfigurationAssemby { get; }
+ public abstract bool UseAssemblyToScanConfigurations { get; }
+ public abstract bool EnableSensitiveDataLogging { get; }
private readonly Auditable _auditor;
- public void Audit() => _auditor.UpdateModifiedAll(ChangeTracker);
+ public virtual void Audit() => _auditor.UpdateModifiedAll(ChangeTracker);
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ base.OnConfiguring(optionsBuilder);
- public abstract void Save();
- public abstract Task SaveAsync(CancellationToken cancellationToken);
+ optionsBuilder.EnableSensitiveDataLogging(UseAssemblyToScanConfigurations);
}
+ public void Save()
+ => SaveChanges();
+
+
+ public async Task SaveAsync(CancellationToken cancellationToken)
+ => await SaveChangesAsync(cancellationToken);
+ public async Task SaveAsync()
+ => await SaveChangesAsync(new CancellationToken(false));
+ protected override void OnModelCreating(ModelBuilder builder)
+ {
+ base.OnModelCreating(builder);
+
+ if (!string.IsNullOrEmpty(Schema) && !string.IsNullOrWhiteSpace(Schema))
+ builder.HasDefaultSchema(Schema);
+ else
+ builder.HasDefaultSchema("IDS");
+
+
+ if (UseAssemblyToScanConfigurations)
+ builder.ApplyConfigurationsFromAssembly(ConfigurationAssemby);
+ }
+}
}
diff --git a/src/Web/Identity/ObjRelMapping/Source/DbContextServices/IdentityDbService.cs b/src/Web/Identity/ObjRelMapping/Source/DbContextServices/IdentityDbService.cs
index bf8e4f0..5049dd6 100644
--- a/src/Web/Identity/ObjRelMapping/Source/DbContextServices/IdentityDbService.cs
+++ b/src/Web/Identity/ObjRelMapping/Source/DbContextServices/IdentityDbService.cs
@@ -5,9 +5,10 @@ namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DbContextServices
using System;
using System.Threading;
using System.Threading.Tasks;
- public interface IdentityDbService : IDisposable, IAsyncDisposable, AuditableDbContext, EntryableDbContext, SetableDbContext
+ public interface IdentityDbService : DbService
{
void Save();
+ Task SaveAsync();
Task SaveAsync(CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/Web/Identity/ObjRelMapping/Source/DependencyResolution/AuditorDIC.cs b/src/Web/Identity/ObjRelMapping/Source/DependencyResolution/AuditorDIC.cs
deleted file mode 100644
index 362de75..0000000
--- a/src/Web/Identity/ObjRelMapping/Source/DependencyResolution/AuditorDIC.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DependencyResolution
-{
- using Microsoft.Extensions.DependencyInjection;
- using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DbContextServices;
- using DotNetCenter.Beyond.ObjRelMapping.Core.Auditing;
- public static class AuditorDIC
- {
- public static IServiceCollection AddAuditor(this IServiceCollection services)
- {
- services.AddTransient();
- return services;
- }
- }
-}
diff --git a/src/Web/Identity/ObjRelMapping/Source/DotNetCenter.Beyond.Web.Identity.ObjRelMapping.csproj b/src/Web/Identity/ObjRelMapping/Source/DotNetCenter.Beyond.Web.Identity.ObjRelMapping.csproj
index 9b11505..8195d2f 100644
--- a/src/Web/Identity/ObjRelMapping/Source/DotNetCenter.Beyond.Web.Identity.ObjRelMapping.csproj
+++ b/src/Web/Identity/ObjRelMapping/Source/DotNetCenter.Beyond.Web.Identity.ObjRelMapping.csproj
@@ -68,14 +68,21 @@
+
-
+
+
+
+
+
+
+
diff --git a/src/Web/Identity/Services/Source/Auditor.cs b/src/Web/Identity/Services/Source/Auditor.cs
new file mode 100644
index 0000000..46e05d8
--- /dev/null
+++ b/src/Web/Identity/Services/Source/Auditor.cs
@@ -0,0 +1,59 @@
+namespace DotNetCenter.Beyond.Web.Identity.Services.DbContextServices
+{
+ using DotNetCenter.Beyond.ObjRelMapping.Core.Auditing;
+ using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
+ using DotNetCenter.Beyond.Web.Identity.Core;
+ using DotNetCenter.Beyond.Web.Identity.Services.Managers;
+ using DotNetCenter.Core.Entities;
+ using DotNetCenter.DateTime.Common;
+ using Microsoft.EntityFrameworkCore;
+ using Microsoft.EntityFrameworkCore.ChangeTracking;
+ using System;
+
+ public class Auditor: Auditable
+ {
+ private readonly CurrentUserService _currentUserService;
+ private readonly CompoundableDateTimeNow _dateTime;
+ public Auditor(CurrentUserService currentUserService, CompoundableDateTimeNow dateTime)
+ {
+ _currentUserService = currentUserService;
+ _dateTime = dateTime;
+ }
+ ///
+ /// Update Modified Informations to all the Entities in change tracker thats in modified state
+ ///
+ ///
+ public virtual void UpdateModifiedAll(ChangeTracker changeTracker)
+ {
+ foreach (var entry in changeTracker.Entries>())
+ switch (entry.State)
+ {
+ //case EntityState.Added:
+ // entry.Entity.EntityCreated(_currentUserService.UserId, _dateTime.DateTimeNow);
+ //break;
+ case EntityState.Modified:
+ entry.Entity.ModifiedBy = _currentUserService.UserId;
+ entry.Entity.ModifiedDateTime = _dateTime.DateTimeNow;
+ break;
+ }
+ }
+ ///
+ /// Update Modified Informations to all the Entities in change tracker thats in modified state
+ ///
+ ///
+ public virtual void UpdateCreatorAll(ChangeTracker changeTracker)
+ {
+ foreach (var entry in changeTracker.Entries>())
+ switch (entry.State)
+ {
+ //case EntityState.Added:
+ // entry.Entity.EntityCreated(_currentUserService.UserId, _dateTime.DateTimeNow);
+ //break;
+ case EntityState.Modified:
+ entry.Entity.CreatedBy = _currentUserService.UserId ?? throw new NullReferenceException();
+ entry.Entity.CreatedDateTime = _dateTime.DateTimeNow;
+ break;
+ }
+ }
+ }
+}
diff --git a/src/Web/Identity/Services/Source/BaseCurrentUserService.cs b/src/Web/Identity/Services/Source/BaseCurrentUserService.cs
index 80cef36..758ff70 100644
--- a/src/Web/Identity/Services/Source/BaseCurrentUserService.cs
+++ b/src/Web/Identity/Services/Source/BaseCurrentUserService.cs
@@ -2,41 +2,53 @@
{
using System;
using System.Security.Claims;
+ using System.Threading;
+ using System.Threading.Tasks;
using DotNetCenter.Beyond.Web.Identity.Core;
- using DotNetCenter.Beyond.Web.Identity.Core.Managers;
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
+ using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+ using DotNetCenter.Beyond.Web.Identity.Services.Managers;
using Microsoft.AspNetCore.Http;
- public abstract class BaseCurrentUserService
+ public abstract class BaseCurrentUserService
: CurrentUserService
+ #region Constraints
+ //dc#1# developer: development cases
+ //Case 2 : For SwitchContects internal
+ where TAppUser : AppUser
+ //Case 1 : For SwitchContects of Code To Generic Types
+ //where TAppUser : class, IAppUser
+ #endregion
{
public BaseCurrentUserService(IHttpContextAccessor httpContextAccessor)
=> HttpContextAccessor = httpContextAccessor;
- public abstract IAppUser TryGetUser(out IAppUser user);
- public bool TrySetUsername()
- {
- var userName = HttpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Name);
- if (string.IsNullOrEmpty(userName) || string.IsNullOrWhiteSpace(userName))
- return false;
+ public abstract TAppUser TryGetUser(out TAppUser user);
+ //public bool TrySetUsername()
+ //{
+ // var userName = HttpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Name);
+ // if (string.IsNullOrEmpty(userName) || string.IsNullOrWhiteSpace(userName))
+ // return false;
- Username = userName;
- return true;
- }
- public bool TrySetUserId()
- {
- var id = HttpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier);
- var isParsed = Guid.TryParse(id, out var userId);
- UserId = Guid.Empty;
- if (!isParsed)
- return false;
+ // Username = userName;
+ // return true;
+ //}
+ //public bool TrySetUserId()
+ //{
+ // var id = HttpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier);
+ // var isParsed = Guid.TryParse(id, out var userId);
+ // UserId = Guid.Empty;
+ // if (!isParsed)
+ // return false;
- UserId = userId;
- return true;
- }
- public Guid UserId { get; protected set; }
+ // UserId = userId;
+ // return true;
+ //}
+ public int? UserId { get; protected set; }
public string Username { get; protected set; }
- public bool IsUserAuthenticated { get => HttpContextAccessor.HttpContext.User.Identity.IsAuthenticated;}
+ public bool IsUserAuthenticated()
+ => HttpContextAccessor.HttpContext.User.Identity.IsAuthenticated;
+ public abstract Task IsUserAuthenticated(CancellationToken cancellationToken);
+
public IHttpContextAccessor HttpContextAccessor { get; }
-
+
}
}
diff --git a/src/Web/Identity/Services/Source/BaseIdentityService.cs b/src/Web/Identity/Services/Source/BaseIdentityService.cs
index 47c265a..6324848 100644
--- a/src/Web/Identity/Services/Source/BaseIdentityService.cs
+++ b/src/Web/Identity/Services/Source/BaseIdentityService.cs
@@ -1,72 +1,65 @@
namespace DotNetCenter.Beyond.Web.Identity.Services
{
+ using DotNetCenter.Beyond.ObjRelMapping.Core.Infrastructure.Common;
using DotNetCenter.Beyond.Web.Identity.Core;
- using DotNetCenter.Beyond.Web.Identity.Core.Managers;
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
+ using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+ using DotNetCenter.Beyond.Web.Identity.Services.Managers;
using DotNetCenter.Core.ErrorHandlers;
using Microsoft.EntityFrameworkCore;
using System;
using System.Threading.Tasks;
- public abstract class BaseIdentityService : IdentityService
+ public abstract class BaseIdentityService: IdentityService
+ where TUserManagerService : UserManagerService
+ where TCurrentUserService : CurrentUserService
+ where TAppUser : IIdentityUser
{
- protected readonly UserManagerService _userManager;
- protected readonly CurrentUserService _currentUserService;
- public BaseIdentityService(UserManagerService userManager,
- CurrentUserService currentUserService)
+ protected readonly TUserManagerService _userManager;
+ protected readonly TCurrentUserService _currentUserService;
+ public BaseIdentityService(TUserManagerService userManager,
+ TCurrentUserService currentUserService)
{
_userManager = userManager;
_currentUserService = currentUserService;
}
- public virtual async Task GetUsernameAsync(Guid userId)
+ public virtual async Task GetUsernameAsync(int userId)
{
- if (!_currentUserService.IsUserAuthenticated)
+ if (!_currentUserService.IsUserAuthenticated())
return "";
var user = await _userManager.Users.FirstOrDefaultAsync(o => o.Id == userId);
- return user.Username;
+ return user.UserName;
}
- public virtual async Task DeleteUserAsync(IAppUser user)
+ public virtual async Task DeleteUserAsync(TAppUser user)
{
var result = await _userManager.DeleteAsync(user);
return result.ToApplicationResult();
}
- public virtual async Task DeleteUserAsync(Guid userId)
+ public virtual async Task DeleteUserAsync(int userId)
{
- IAppUser user = await GetUserFormUserManagerAsync(userId);
+ TAppUser user = await GetUserFormUserManagerAsync(userId);
var result = await _userManager.DeleteAsync(user);
return result.ToApplicationResult();
}
- private async Task GetUserFormUserManagerAsync(Guid userId)
+ private async Task GetUserFormUserManagerAsync(int? userId)
{
- return await _userManager.Users.FirstAsync(o => o.Id.CompareTo(userId) == 0);
+ return await _userManager.Users?.FirstAsync(o => o.Id == userId);
}
public virtual async Task DeleteCurrentUserAsync()
{
- if (!_currentUserService.IsUserAuthenticated)
+ if (!_currentUserService.IsUserAuthenticated())
return new ResultContainer(false, new[] { "" });
var user = await GetUserFormUserManagerAsync(_currentUserService.UserId);
var result = await _userManager.DeleteAsync(user);
return result.ToApplicationResult();
}
-
- public async Task<(ResultContainer Result, Guid UserId)> CreateUserAsync(string userName, string password)
- {
- var user = new AppUser(Guid.NewGuid(), DateTime.UtcNow)
- {
- UserName = userName,
- };
-
- var result = await _userManager.CreateAsync(user);
-
- return (result.ToApplicationResult(), user.Id);
- }
+ public abstract Task<(ResultContainer Result, int UserId)> CreateUserAsync(TAppUser user);
}
}
diff --git a/src/Web/Identity/Services/Source/CurrentUserService.cs b/src/Web/Identity/Services/Source/CurrentUserService.cs
new file mode 100644
index 0000000..7fc661f
--- /dev/null
+++ b/src/Web/Identity/Services/Source/CurrentUserService.cs
@@ -0,0 +1,14 @@
+namespace DotNetCenter.Beyond.Web.Identity.Services.Managers
+{
+ using System;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ public interface CurrentUserService
+ {
+ int? UserId { get; }
+ string Username { get; }
+ public bool IsUserAuthenticated();
+ public Task IsUserAuthenticated(CancellationToken cancellationToken);
+ }
+}
diff --git a/src/Web/Identity/Services/Source/DependencyResolution/AuditorDIC.cs b/src/Web/Identity/Services/Source/DependencyResolution/AuditorDIC.cs
new file mode 100644
index 0000000..2b405b1
--- /dev/null
+++ b/src/Web/Identity/Services/Source/DependencyResolution/AuditorDIC.cs
@@ -0,0 +1,20 @@
+using DotNetCenter.Beyond.ObjRelMapping.Core.Auditing;
+using DotNetCenter.Beyond.Web.Identity.Services.DbContextServices;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DotNetCenter.Beyond.Web.Identity.Services.DependencyResolution
+{
+ public static class AuditorDIC
+ {
+ public static IServiceCollection AddAuditor(this IServiceCollection services)
+ {
+ services.AddSingleton();
+ return services;
+ }
+ }
+}
diff --git a/src/Web/Identity/ObjRelMapping/Source/DependencyResolution/IdentityDbServicesDIC.cs b/src/Web/Identity/Services/Source/DependencyResolution/IdentityDbServicesDIC.cs
similarity index 64%
rename from src/Web/Identity/ObjRelMapping/Source/DependencyResolution/IdentityDbServicesDIC.cs
rename to src/Web/Identity/Services/Source/DependencyResolution/IdentityDbServicesDIC.cs
index 33b10cd..366b1f8 100644
--- a/src/Web/Identity/ObjRelMapping/Source/DependencyResolution/IdentityDbServicesDIC.cs
+++ b/src/Web/Identity/Services/Source/DependencyResolution/IdentityDbServicesDIC.cs
@@ -1,15 +1,16 @@
-namespace DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DependencyResolution
+namespace DotNetCenter.Beyond.Web.Identity.Services.DependencyResolution
{
+ using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.DbContextServices;
using Microsoft.Extensions.DependencyInjection;
public static class IdentityDbServicesDIC
{
- public static IServiceCollection AddIdentityDbServices(this IServiceCollection services)
- where TServiceDbContext : IdentityDbService
+ public static IServiceCollection AddIdentityDbServices(this IServiceCollection services)
where TImplementationDbContext : class, IdentityDbService
{
services.AddTransient();
+ services.AddTransient();
services.AddAuditor();
return services;
}
diff --git a/src/Web/Identity/Services/Source/DependencyResolution/IdentityServicesDIC.cs b/src/Web/Identity/Services/Source/DependencyResolution/IdentityServicesDIC.cs
deleted file mode 100644
index 997f320..0000000
--- a/src/Web/Identity/Services/Source/DependencyResolution/IdentityServicesDIC.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace DotNetCenter.Beyond.Web.Identity.Services.DependencyResolution
-{
- using DotNetCenter.Beyond.Web.Identity.Core;
- using DotNetCenter.Beyond.Web.Identity.Services;
- using Microsoft.AspNetCore.Mvc.RazorPages;
- using Microsoft.Extensions.DependencyInjection;
- using System;
-
- public static class IdentityServicesDIC
- {
- public static IServiceCollection AddIdentityServices(this IServiceCollection services)
- {
- return services;
- }
- }
-}
diff --git a/src/Web/Identity/Services/Source/DependencyResolution/ManagerServicesDIC.cs b/src/Web/Identity/Services/Source/DependencyResolution/ManagerServicesDIC.cs
new file mode 100644
index 0000000..87c0490
--- /dev/null
+++ b/src/Web/Identity/Services/Source/DependencyResolution/ManagerServicesDIC.cs
@@ -0,0 +1,19 @@
+using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+using DotNetCenter.Beyond.Web.Identity.Services.Managers;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace DotNetCenter.Beyond.Web.Identity.Services.DependencyResolution
+{
+ public static class ManagerServicesDIC
+ {
+ public static IServiceCollection AddManagerServices(this IServiceCollection services)
+ where TUserManager : class, UserManagerService
+ where TSignInManager : class, SignInManagerService
+ where TAppUser : IIdentityUser
+ {
+ services.AddSingleton, TUserManager>();
+ services.AddSingleton, TSignInManager>();
+ return services;
+ }
+ }
+}
diff --git a/src/Web/Identity/Services/Source/DotNetCenter.Beyond.Web.Identity.Services.csproj b/src/Web/Identity/Services/Source/DotNetCenter.Beyond.Web.Identity.Services.csproj
index 5afd865..469d576 100644
--- a/src/Web/Identity/Services/Source/DotNetCenter.Beyond.Web.Identity.Services.csproj
+++ b/src/Web/Identity/Services/Source/DotNetCenter.Beyond.Web.Identity.Services.csproj
@@ -63,6 +63,7 @@
+
diff --git a/src/Web/Identity/Services/Source/IdentityService.cs b/src/Web/Identity/Services/Source/IdentityService.cs
new file mode 100644
index 0000000..c34c09a
--- /dev/null
+++ b/src/Web/Identity/Services/Source/IdentityService.cs
@@ -0,0 +1,14 @@
+namespace DotNetCenter.Beyond.Web.Identity.Services
+{
+ using System;
+ using System.Threading.Tasks;
+ using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
+ using DotNetCenter.Core.ErrorHandlers;
+ public interface IdentityService
+ where TAppUser : IIdentityUser
+ {
+ Task GetUsernameAsync(int userId);
+ Task<(ResultContainer Result, int UserId)> CreateUserAsync(TAppUser user);
+ Task DeleteUserAsync(int userId);
+ }
+}
diff --git a/src/Web/Identity/Services/Source/Managers/BaseAppSignInManager.cs b/src/Web/Identity/Services/Source/Managers/BaseAppSignInManager.cs
index 2955dc1..570b6ef 100644
--- a/src/Web/Identity/Services/Source/Managers/BaseAppSignInManager.cs
+++ b/src/Web/Identity/Services/Source/Managers/BaseAppSignInManager.cs
@@ -1,7 +1,6 @@
namespace DotNetCenter.Beyond.Web.Identity.Services.Managers
{
- using DotNetCenter.Beyond.Web.Identity.Core.Managers;
- using DotNetCenter.Beyond.Web.Identity.Core.Models;
+ using DotNetCenter.Beyond.Web.Identity.ObjRelMapping.Common.Models;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
@@ -12,17 +11,24 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
- public abstract class BaseAppSignInManager
- : SignInManager, SignInManagerService
+ public abstract class BaseAppSignInManager
+ : SignInManager, SignInManagerService
+ #region Constraints
+ //dc#1# developer: development cases
+ //Case 2 : For SwitchContects internal
+ where TAppUser : AppUser
+ //Case 1 : For SwitchContects of Code To Generic Types
+ //where TAppUser : class, IAppUser
+ #endregion
{
protected BaseAppSignInManager(
- UserManager userManager,
+ UserManager userManager,
IHttpContextAccessor contextAccessor,
- IUserClaimsPrincipalFactory claimsFactory,
+ IUserClaimsPrincipalFactory claimsFactory,
IOptions optionsAccessor,
- ILogger