From 335fd95d234b7b40796cf71cec85e159f788496d Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 30 Jul 2026 14:27:17 +0330 Subject: [PATCH] refactor and add using constants instead of hard coded strings ... --- Constants/XCategoryServiceConstants.cs | 7 ++++++- DI/XDIHelperExtension.cs | 12 ++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Constants/XCategoryServiceConstants.cs b/Constants/XCategoryServiceConstants.cs index 22329b1..41f66b1 100644 --- a/Constants/XCategoryServiceConstants.cs +++ b/Constants/XCategoryServiceConstants.cs @@ -24,7 +24,7 @@ namespace xCategoryService.Constants public const string XCategoryEntityHub = "categoryEntity"; public const string XSubCategoryDtoHub = "subCategoryDto"; public const string XSubCategoryEntityHub = "subCategoryEntity"; - + // // Custome Constants ... public const string SubCategoryReference = "SubCat"; @@ -32,5 +32,10 @@ namespace xCategoryService.Constants public const string CategoryDescriptionResourceIdentifier = "CatD"; public const string SubCategoryTitleResourceIdentifier = "SubCatT"; public const string SubCategoryDescriptionResourceIdentifier = "SubCatD"; + + // + // EF Repositories Helper Extensions ... + public const string GetXCategoryEFRepositoryDescriptor = "GetXCategoryEFRepositoryDescriptor"; + public const string GetXSubCategoryEFRepositoryDescriptor = "GetXSubCategoryEFRepositoryDescriptor"; } } \ No newline at end of file diff --git a/DI/XDIHelperExtension.cs b/DI/XDIHelperExtension.cs index 6b7ac49..480d9fc 100644 --- a/DI/XDIHelperExtension.cs +++ b/DI/XDIHelperExtension.cs @@ -205,8 +205,8 @@ namespace xCategoryService.DI // // Count Data in Category ... - var hasCategory = (categoryProvider.Count().GetAwaiter().GetResult()) > 0; - var hasSubCategory = (subCategoryProvider.Count().GetAwaiter().GetResult()) > 0; + var hasCategory = categoryProvider.Count().GetAwaiter().GetResult() > 0; + var hasSubCategory = subCategoryProvider.Count().GetAwaiter().GetResult() > 0; // // Seed Category Resources ... @@ -370,18 +370,18 @@ namespace xCategoryService.DI // Category ... categoryDescriptor = typeof(XCategoryServiceHelper) .InvokeGenericMethod( - methodName: "GetXCategoryEFRepositoryDescriptor", + args: null, runtimeType: contextType, - args: null + methodName: XCategoryServiceConstants.GetXCategoryEFRepositoryDescriptor ); // // SubCategory ... subCategoryDescriptor = typeof(XCategoryServiceHelper) .InvokeGenericMethod( - methodName: "GetXSubCategoryEFRepositoryDescriptor", + args: null, runtimeType: contextType, - args: null + methodName: XCategoryServiceConstants.GetXSubCategoryEFRepositoryDescriptor ); break;