From 8fc798746ffe2e68b03369ac134ba8b54314842e Mon Sep 17 00:00:00 2001 From: mahan Date: Thu, 27 Nov 2025 12:45:18 +0330 Subject: [PATCH] Refactor error handling and IHttpContextAccessor usage Simplified error message construction in RoleApplication.cs by removing redundant properties. Refactored IHttpContextAccessor registration in Program.cs to use the service provider after app initialization. Removed redundant no-op code in NullFaceEmbeddingNotificationService.cs. --- .../NullFaceEmbeddingNotificationService.cs | 1 - AccountManagement.Application/RoleApplication.cs | 2 +- ServiceHost/Program.cs | 13 +++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/0_Framework/InfraStructure/NullFaceEmbeddingNotificationService.cs b/0_Framework/InfraStructure/NullFaceEmbeddingNotificationService.cs index c760d2cd..5ce50b51 100644 --- a/0_Framework/InfraStructure/NullFaceEmbeddingNotificationService.cs +++ b/0_Framework/InfraStructure/NullFaceEmbeddingNotificationService.cs @@ -27,4 +27,3 @@ public class NullFaceEmbeddingNotificationService : IFaceEmbeddingNotificationSe return Task.CompletedTask; } } - diff --git a/AccountManagement.Application/RoleApplication.cs b/AccountManagement.Application/RoleApplication.cs index 1342ac16..c2714f36 100644 --- a/AccountManagement.Application/RoleApplication.cs +++ b/AccountManagement.Application/RoleApplication.cs @@ -58,7 +58,7 @@ public class RoleApplication : IRoleApplication { _unitOfWork.RollbackAccountContext(); - return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد"+response.Result.errorMessage +response.Result.ErrorType + response.Error); + return operation.Failed("ارتباط با اپلیکیش پروگرام منیجر برقرار نشد"+ response.Error); } if (!response.Result.isSuccess) diff --git a/ServiceHost/Program.cs b/ServiceHost/Program.cs index f6f0b770..ee11c8e8 100644 --- a/ServiceHost/Program.cs +++ b/ServiceHost/Program.cs @@ -331,15 +331,16 @@ builder.Services.AddParbad().ConfigureGateways(gateways => storage.UseMemoryCache(); }); -#region GetHttpContext - -var httpContextAccessor = new HttpContextAccessor(); -builder.Services.AddSingleton(httpContextAccessor); - -#endregion var app = builder.Build(); + +#region GetHttpContext + +var httpContextAccessor = app.Services.GetRequiredService(); + + +#endregion app.UseCors("AllowSpecificOrigins"); #region InternalProgarmManagerApi