Implemented an API endpoint that retrieves the number of planned tasks and completed tasks for a specific project on a given date #72

Merged
vikas.nale merged 1 commits from Ashutosh_Task#348_Activities_Report into Issue_May_4W 2025-05-24 06:35:34 +00:00
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
  • 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
- **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
vikas.nale merged commit 56aeceb1f9 into Issue_May_4W 2025-05-24 06:35:34 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/marco.pms.api#72
No description provided.