Implemented an API endpoint that retrieves the number of planned tasks and completed tasks for a specific project on a given date #72
Collaborator
- Get Tenant and Employee Info:
- Retrieve the current tenant ID using _userHelper.GetTenantId().
- Retrieve the currently logged-in employee using _userHelper.GetCurrentEmployeeAsync().
- Handle Optional Date Input:
- Set currentDate to DateTime.UtcNow by default.
- If a date is passed and is invalid (fails DateTime.TryParse):
- Log an error and return a 400 Bad Request with message "Invalid date.".
- Fetch Project:
- Query the Projects table by projectId.
- If the project is not found:
- Log an error including the employee ID and date.
- Return a 404 Not Found with message "Project not found".
- Hierarchical Data Fetch:
- Fetch buildings related to the project.
- From those buildings, fetch all floors.
- From those floors, fetch all work areas.
- From those areas, fetch all work items, including their linked ActivityMaster.
- Fetch Task Allocations:
- From the collected work items, fetch task allocations matching:
- The WorkItemId
- The specified or current AssignmentDate
- From the collected work items, fetch task allocations matching:
- Compute Task Totals:
- Loop through the matched tasks to calculate:
- totalPlannedTask — the sum of all PlannedTask values
- totalCompletedTask — the sum of all CompletedTask values
- Loop through the matched tasks to calculate:
- Prepare Dashboard Response:
- Create a TasksDashboardVM object with:
- TotalTasks and CompletedTasks
- Create a TasksDashboardVM object with:
- Logging and Response:
- Log an info message with project ID, date, and employee ID.
- Return a 200 OK response with the task summary using ApiResponse
- **Get Tenant and Employee Info**:
- Retrieve the current tenant ID using _userHelper.GetTenantId().
- Retrieve the currently logged-in employee using _userHelper.GetCurrentEmployeeAsync().
- **Handle Optional Date Input**:
- Set currentDate to DateTime.UtcNow by default.
- If a date is passed and is invalid (fails DateTime.TryParse):
- Log an error and return a 400 Bad Request with message "Invalid date.".
- **Fetch Project**:
- Query the Projects table by projectId.
- If the project is not found:
- Log an error including the employee ID and date.
- Return a 404 Not Found with message "Project not found".
- **Hierarchical Data Fetch**:
- Fetch buildings related to the project.
- From those buildings, fetch all floors.
- From those floors, fetch all work areas.
- From those areas, fetch all work items, including their linked ActivityMaster.
- **Fetch Task Allocations**:
- From the collected work items, fetch task allocations matching:
- The WorkItemId
- The specified or current AssignmentDate
- **Compute Task Totals**:
- Loop through the matched tasks to calculate:
- totalPlannedTask — the sum of all PlannedTask values
- totalCompletedTask — the sum of all CompletedTask values
- **Prepare Dashboard Response**:
- Create a TasksDashboardVM object with:
- TotalTasks and CompletedTasks
- **Logging and Response**:
- Log an info message with project ID, date, and employee ID.
- Return a 200 OK response with the task summary using ApiResponse<object>.SuccessResponse(...).
ashutosh.nehete
added 1 commit 2025-05-24 05:20:51 +00:00
Merge pull request 'Implemented an API endpoint that retrieves the number of planned tasks and completed tasks for a specific project on a given date' (#72) from Ashutosh_Task#348_Activities_Report into Issue_May_4W
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "Ashutosh_Task#348_Activities_Report"
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?