-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from BirajMainali/chore/app
Chore/app
- Loading branch information
Showing
59 changed files
with
1,265 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace App.Base.Configurations; | ||
|
||
public interface IScopedDependency; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace App.Base.Configurations; | ||
|
||
public interface ITransientDependency; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace App.Base.Constants; | ||
|
||
public class AuthenticationKeyConstants | ||
{ | ||
public const string AuthenticationKey = "damn-unique-authentication-key-x"; | ||
public const string MultiTenantAuthenticationKey = "damn-unique-multi-tenant-authentication-key-x"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace App.Base.Constants; | ||
|
||
public static class ClaimsConstants | ||
{ | ||
public static string ProtectedClaimsKey = "protected-extra-claims"; | ||
public static string ProtectedClaimsHttpClaimKey = "protected-extra-claims-http-claim"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
#nullable enable | ||
using System; | ||
using System; | ||
using App.Base.Constants; | ||
|
||
namespace App.Base.Entities | ||
{ | ||
public abstract class FullAuditedEntity<TKey> | ||
{ | ||
public TKey Id { get; set; } | ||
public DateTime CreatedDate { get; set; } = DateTime.Now; | ||
public DateTime CreatedDate { get; set; } = DateTime.UtcNow; | ||
public DateTime? UpdatedDate { get; set; } | ||
public char RecStatus { get; set; } = Status.Active; | ||
public TKey CreatedBy { get; set; } | ||
public TKey UpdatedBy { get; set; } | ||
public string? CreatedBy { get; set; } | ||
public string? UpdatedBy { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Text.Json; | ||
|
||
namespace App.Base.Extensions; | ||
|
||
public static class JsonExtension | ||
{ | ||
public static string ToJson<T>(this T value, Action<JsonSerializerOptions>? options = null) | ||
{ | ||
var newOptions = new JsonSerializerOptions(); | ||
options?.Invoke(newOptions); | ||
return JsonSerializer.Serialize(value, newOptions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using App.Base.Providers.Interface; | ||
using App.Base.Settings; | ||
using Microsoft.Extensions.Options; | ||
using Npgsql; | ||
|
||
namespace App.Base.Providers | ||
{ | ||
public class DatabaseConnectionProvider : IDatabaseConnectionProvider | ||
{ | ||
private readonly IOptions<AppSettings> _appSettings; | ||
|
||
public DatabaseConnectionProvider(IOptions<AppSettings> appSettings) | ||
{ | ||
_appSettings = appSettings; | ||
} | ||
|
||
/// <summary> | ||
/// Ready to use NpgsqlConnection | ||
/// </summary> | ||
/// <returns></returns> | ||
public NpgsqlConnection GetConnection() | ||
{ | ||
var defaultConnection = _appSettings.Value.ConnectionStrings.DefaultConnection; | ||
return new NpgsqlConnection(defaultConnection); | ||
} | ||
|
||
public string GetConnectionString(string databaseName) | ||
{ | ||
var defaultConnection = _appSettings.Value.ConnectionStrings.DefaultConnection; | ||
var builder = new NpgsqlConnectionStringBuilder(defaultConnection) | ||
{ | ||
Database = databaseName | ||
}; | ||
return builder.ConnectionString; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
App.Base/Providers/Interface/IDatabaseConnectionProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using App.Base.Configurations; | ||
using Npgsql; | ||
|
||
namespace App.Base.Providers.Interface | ||
{ | ||
public interface IDatabaseConnectionProvider : IScopedDependency | ||
{ | ||
NpgsqlConnection GetConnection(); | ||
string GetConnectionString(string databaseName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace App.Base.Settings | ||
{ | ||
public class AppSettings | ||
{ | ||
public ConnectionStrings ConnectionStrings { get; set; } | ||
public bool UseMultiTenancy { get; set; } = false; | ||
public string DefaultDataProtectionPurpose { get; set; } | ||
} | ||
|
||
public class ConnectionStrings | ||
{ | ||
public string DefaultConnection { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using App.Base.Entities; | ||
|
||
namespace App.User.Entity; | ||
|
||
public class ApplicationTenant : FullAuditedEntity<Guid> | ||
{ | ||
public string Name { get; protected set; } | ||
public string DatabaseName { get; protected set; } | ||
|
||
public ApplicationTenant() | ||
{ | ||
} | ||
|
||
public ApplicationTenant(string name, string databaseName) | ||
=> Copy(name, databaseName); | ||
private void Copy(string name, string databaseName) | ||
{ | ||
Name = name; | ||
DatabaseName = databaseName; | ||
} | ||
} |
Oops, something went wrong.