Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions TestHosts/TestHosts/Controllers/DeveloperController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace TestHosts.Controllers
public class DeveloperController : ControllerBase
{
private readonly IDbContextResolver<PataPawaContext> ContextResolver;
private const String PataPawaReadModelKey = "PataPawaReadModel";

public DeveloperController(IDbContextResolver<PataPawaContext> contextResolver) {
this.ContextResolver = contextResolver;
}
Expand All @@ -27,7 +27,7 @@ public DeveloperController(IDbContextResolver<PataPawaContext> contextResolver)
[Route("patapawaprepay/createuser")]
public async Task<IActionResult> CreatePrepayUser([FromBody] CreatePatapawaPrePayUser request, CancellationToken cancellationToken){

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

Guid userId = Guid.NewGuid();

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

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

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

Guid meterId = Guid.NewGuid();

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

Guid billIdentifier = Guid.NewGuid();

Expand Down
3 changes: 1 addition & 2 deletions TestHosts/TestHosts/Database/PataPawa/PataPawaContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ namespace TestHosts.Database.PataPawa
public class PataPawaContext : DbContext
{
private readonly String ConnectionString;
private const String PataPawaReadModelKey = "PataPawaReadModel";
public PataPawaContext()
{
// This is the migration connection string

// Get connection string from configuration.
this.ConnectionString = ConfigurationReader.GetConnectionString(PataPawaReadModelKey);
this.ConnectionString = ConfigurationReader.GetConnectionString(Constants.PataPawaReadModelConfig);
}

public PataPawaContext(String connectionString)
Expand Down
Loading
Loading