Implemented filtering functionality for Get Contact List API #67
Collaborator
- Get Tenant and Employee Info:
- Retrieve the current tenant ID using _userHelper.GetTenantId().
- Get the currently logged-in employee using _userHelper.GetCurrentEmployeeAsync().
- Get Employee's Buckets:
- Fetch all EmployeeBucketMappings related to the employee.
- Extract all BucketIds from these mappings.
- Apply Bucket Filter (if provided):
- If filterDto.BucketIds is specified, override the employee's buckets with the filtered ones.
- Find Related Contacts:
- Use the final bucketIds to get all ContactBucketMappings.
- Extract ContactIds from these mappings to identify relevant contacts.
- Apply Category Filter (if provided):
- If filterDto.CategoryIds is given, only include contacts that belong to the selected categories.
- Otherwise, include all contacts from the given buckets that are active and match the tenant.
- Load Related Data:
- Fetch contact phone numbers, emails, tags, and project mappings from the database.
- Also fetch the tag details from ContactTagMasters.
- Apply Search Filter (if provided):
- If a search string is provided:
- Filter contacts by matching phone number or email address.
- Further filter contacts by name or organization.
- Combine all matching ContactIds and apply filtering to the contacts list.
- If a search string is provided:
- Build View Models (ContactVM):
- For each contact:
- Map phone numbers to ContactPhoneVM
- Map emails to ContactEmailVM
- Map tag mappings to ContactTagVM using tag metadata
- Collect associated project and bucket IDs
- Compose a full ContactVM with all this data
- For each contact:
- Logging and Response:
- Log the number of contacts fetched and the employee ID.
- Return a success response with the list of ContactVMs and a success message.
- **Get Tenant and Employee Info**:
- Retrieve the current tenant ID using _userHelper.GetTenantId().
- Get the currently logged-in employee using _userHelper.GetCurrentEmployeeAsync().
- **Get Employee's Buckets**:
- Fetch all EmployeeBucketMappings related to the employee.
- Extract all BucketIds from these mappings.
- **Apply Bucket Filter (if provided)**:
- If filterDto.BucketIds is specified, override the employee's buckets with the filtered ones.
- **Find Related Contacts**:
- Use the final bucketIds to get all ContactBucketMappings.
- Extract ContactIds from these mappings to identify relevant contacts.
- **Apply Category Filter (if provided)**:
- If filterDto.CategoryIds is given, only include contacts that belong to the selected categories.
- Otherwise, include all contacts from the given buckets that are active and match the tenant.
- **Load Related Data**:
- Fetch contact phone numbers, emails, tags, and project mappings from the database.
- Also fetch the tag details from ContactTagMasters.
- **Apply Search Filter (if provided)**:
- If a search string is provided:
- Filter contacts by matching phone number or email address.
- Further filter contacts by name or organization.
- Combine all matching ContactIds and apply filtering to the contacts list.
- **Build View Models (ContactVM)**:
- For each contact:
- Map phone numbers to ContactPhoneVM
- Map emails to ContactEmailVM
- Map tag mappings to ContactTagVM using tag metadata
- Collect associated project and bucket IDs
- Compose a full ContactVM with all this data
- **Logging and Response**:
- Log the number of contacts fetched and the employee ID.
- Return a success response with the list of ContactVMs and a success message.
ashutosh.nehete
added 1 commit 2025-05-22 11:57:52 +00:00
Merge pull request 'Implemented filtering functionality for Get Contact List API' (#67) from AshutoshEnhancement#332_Added_Filter_To_Contact_List into Feature_Directory
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "AshutoshEnhancement#332_Added_Filter_To_Contact_List"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?