From 376af6828eff3b4297cfb83a0f6715ec6dd4568c Mon Sep 17 00:00:00 2001 From: dibakor Date: Tue, 14 Jul 2026 12:46:54 +0600 Subject: [PATCH] applied logic in employee integretion for app role type --- .../Integrations/IntegrationService.cs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/Integrations/IntegrationService.cs b/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/Integrations/IntegrationService.cs index 93d59d8..174f563 100644 --- a/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/Integrations/IntegrationService.cs +++ b/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/Integrations/IntegrationService.cs @@ -150,6 +150,7 @@ public class IntegrationService : IIntegrationService response.IsUpdated = false; } + int roleTypeId = GetRegionAreaTerritoryLevel(request); bool isUserExist = await IsUserExistByEmployeeNumberAsync(tc, request.EmployeeVendorCode); if (!isUserExist) @@ -164,7 +165,7 @@ public class IntegrationService : IIntegrationService EmailAddress = request.Mail, IsLocked = 0, Password ="12345", - UserRoleType = request.Designation == "01"? (int)UserRoleTypeEnum.OrderCollector : null, + UserRoleType = roleTypeId, UserPlatformId = (int)UserPlatFormType.AppUser, EmployeeNumber = request.EmployeeVendorCode }; @@ -191,9 +192,28 @@ public class IntegrationService : IIntegrationService return response; } - private int DecideEmployeeAppRole(IntegrationEmployeeRequest request) + private int GetRegionAreaTerritoryLevel(IntegrationEmployeeRequest request) { + bool hasRegion = !string.IsNullOrWhiteSpace(request.RegionAreaCode); + bool hasArea = !string.IsNullOrWhiteSpace(request.AreaAVSalesUnitCode); + bool hasTerritory = !string.IsNullOrWhiteSpace(request.Territory); + if (hasRegion && hasArea && hasTerritory) + { + return (int)UserRoleTypeEnum.OrderCollector; + } + + if (hasRegion && hasArea && !hasTerritory) + { + return (int)UserRoleTypeEnum.OrderValidator; + } + + if (hasRegion && !hasArea && !hasTerritory) + { + return (int)UserRoleTypeEnum.OrderApprover; + } + + return 0; } public async Task UpsertMaterialAsync(IntegrationMaterialRequest request)