Skip to content

Commit

Permalink
expose 2nd sql server on a test port
Browse files Browse the repository at this point in the history
add logging to create doctor handler
  • Loading branch information
ardalis committed Mar 4, 2022
1 parent 91a2ba1 commit fefa36f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
using System.Threading;
using System.Threading.Tasks;
using FrontDesk.Core.SyncedAggregates;
using MediatR;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;

namespace FrontDesk.Infrastructure.Data.Sync
{

public class CreateDoctorHandler : IRequestHandler<CreateDoctorCommand>
{
private readonly AppDbContext _dbContext;
private readonly ILogger<CreateDoctorHandler> _logger;

public CreateDoctorHandler(AppDbContext dbContext)
public CreateDoctorHandler(AppDbContext dbContext,
ILogger<CreateDoctorHandler> logger)
{
_dbContext = dbContext;
_logger = logger;
}
public async Task<Unit> Handle(CreateDoctorCommand request, CancellationToken cancellationToken)
{
_logger.LogInformation($"Creating new Doctor in FrontDesk database: {request.Name}");
string insertSQLFormat = "SET IDENTITY_INSERT {0} ON\nINSERT INTO {0} (Id, Name) VALUES (@Id, @Name)\nSET IDENTITY_INSERT {0} OFF";

string command = string.Format(insertSQLFormat, "Doctors");
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ services:
environment:
SA_PASSWORD: "P@ssW0rd!"
ACCEPT_EULA: "Y"
ports:
- 1435:1433 # exposed just for debugging purposes

clinicmanagement-api:
build:
Expand Down

0 comments on commit fefa36f

Please sign in to comment.