Skip to content

Commit dae88bf

Browse files
Merge pull request #151 from TransactionProcessing/task/#143_codact_password_issues
Refactor: centralize config keys in Constants class
2 parents 288ac66 + 0bf76b1 commit dae88bf

4 files changed

Lines changed: 178 additions & 188 deletions

File tree

TestHosts/TestHosts/Controllers/DeveloperController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace TestHosts.Controllers
1818
public class DeveloperController : ControllerBase
1919
{
2020
private readonly IDbContextResolver<PataPawaContext> ContextResolver;
21-
private const String PataPawaReadModelKey = "PataPawaReadModel";
21+
2222
public DeveloperController(IDbContextResolver<PataPawaContext> contextResolver) {
2323
this.ContextResolver = contextResolver;
2424
}
@@ -27,7 +27,7 @@ public DeveloperController(IDbContextResolver<PataPawaContext> contextResolver)
2727
[Route("patapawaprepay/createuser")]
2828
public async Task<IActionResult> CreatePrepayUser([FromBody] CreatePatapawaPrePayUser request, CancellationToken cancellationToken){
2929

30-
using ResolvedDbContext<PataPawaContext>? resolvedContext = this.ContextResolver.Resolve(PataPawaReadModelKey);
30+
using ResolvedDbContext<PataPawaContext>? resolvedContext = this.ContextResolver.Resolve(Constants.PataPawaReadModelConfig);
3131

3232
Guid userId = Guid.NewGuid();
3333

@@ -57,7 +57,7 @@ await resolvedContext.Context.PrePayUsers.AddAsync(new PrePayUser
5757
[Route("patapawaprepay/adduserdebt")]
5858
public async Task<IActionResult> AddUserDebt([FromBody] AddPatapawaPrePayUserDebt request, CancellationToken cancellationToken)
5959
{
60-
using ResolvedDbContext<PataPawaContext>? resolvedContext = this.ContextResolver.Resolve(PataPawaReadModelKey);
60+
using ResolvedDbContext<PataPawaContext>? resolvedContext = this.ContextResolver.Resolve(Constants.PataPawaReadModelConfig);
6161

6262
PrePayUser user = await resolvedContext.Context.PrePayUsers.SingleOrDefaultAsync(u => u.UserName == request.UserName, cancellationToken);
6363

@@ -75,7 +75,7 @@ public async Task<IActionResult> AddUserDebt([FromBody] AddPatapawaPrePayUserDeb
7575
[HttpPost]
7676
[Route("patapawaprepay/createmeter")]
7777
public async Task<IActionResult> CreatePrepayMeter([FromBody] CreatePatapawaPrePayMeter request, CancellationToken cancellationToken){
78-
using ResolvedDbContext<PataPawaContext>? resolvedContext = this.ContextResolver.Resolve(PataPawaReadModelKey);
78+
using ResolvedDbContext<PataPawaContext>? resolvedContext = this.ContextResolver.Resolve(Constants.PataPawaReadModelConfig);
7979

8080
Guid meterId = Guid.NewGuid();
8181

@@ -101,7 +101,7 @@ await resolvedContext.Context.PrePayMeters.AddAsync(new PrePayMeter
101101
public async Task<IActionResult> CreateHostConfiguration([FromBody] CreatePataPawaPostPayBill request,
102102
CancellationToken cancellationToken)
103103
{
104-
using ResolvedDbContext<PataPawaContext>? resolvedContext = this.ContextResolver.Resolve(PataPawaReadModelKey);
104+
using ResolvedDbContext<PataPawaContext>? resolvedContext = this.ContextResolver.Resolve(Constants.PataPawaReadModelConfig);
105105

106106
Guid billIdentifier = Guid.NewGuid();
107107

TestHosts/TestHosts/Database/PataPawa/PataPawaContext.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ namespace TestHosts.Database.PataPawa
99
public class PataPawaContext : DbContext
1010
{
1111
private readonly String ConnectionString;
12-
private const String PataPawaReadModelKey = "PataPawaReadModel";
1312
public PataPawaContext()
1413
{
1514
// This is the migration connection string
1615

1716
// Get connection string from configuration.
18-
this.ConnectionString = ConfigurationReader.GetConnectionString(PataPawaReadModelKey);
17+
this.ConnectionString = ConfigurationReader.GetConnectionString(Constants.PataPawaReadModelConfig);
1918
}
2019

2120
public PataPawaContext(String connectionString)

0 commit comments

Comments
 (0)