Renames core domain entities and services from "User" to "Account" Refactors project-wide namespaces, classes, and database tables to use "Account" terminology Updates related components, services, and database schema to reflect new domain naming Standardizes naming conventions across authentication and organization setup features
43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using System.Diagnostics;
|
|
using Microsoft.ApplicationInsights;
|
|
using Microsoft.ApplicationInsights.DataContracts;
|
|
using PlanTempus.Core.CommandQueries;
|
|
|
|
namespace PlanTempus.Components.Accounts.Create;
|
|
|
|
public class CommandHandlerDecorator<TCommand>(
|
|
ICommandHandler<TCommand> decoratedHandler,
|
|
TelemetryClient telemetryClient) : ICommandHandler<TCommand>, ICommandHandlerDecorator where TCommand : ICommand
|
|
{
|
|
public async Task<CommandResponse> Handle(TCommand command)
|
|
{
|
|
command.TransactionId = Guid.NewGuid();
|
|
using var operation =
|
|
telemetryClient.StartOperation<RequestTelemetry>($"Handle {decoratedHandler.GetType().FullName}",
|
|
command.CorrelationId.ToString());
|
|
try
|
|
{
|
|
operation.Telemetry.Properties["CorrelationId"] = command.CorrelationId.ToString();
|
|
operation.Telemetry.Properties["TransactionId"] = command.TransactionId.ToString();
|
|
|
|
var result = await decoratedHandler.Handle(command);
|
|
|
|
operation.Telemetry.Properties["RequestId"] = result.RequestId.ToString();
|
|
operation.Telemetry.Success = true;
|
|
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
operation.Telemetry.Success = false;
|
|
|
|
telemetryClient.TrackException(ex, new Dictionary<string, string>
|
|
{
|
|
["CorrelationId"] = command.CorrelationId.ToString(),
|
|
["Command"] = command.GetType().Name,
|
|
["CommandHandler"] = decoratedHandler.GetType().FullName
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
}
|