Implemented an API endpoint that retrieves the attendance records for a specific project on a given date #71

Merged
vikas.nale merged 1 commits from Ashutosh_Task#347_Project_Attendance_Report into Issue_May_4W 2025-05-24 04:58:06 +00:00
Collaborator
  • Get Tenant and Employee Info:
    • Retrieves the current tenant ID using _userHelper.GetTenantId().
    • Retrieves the logged-in employee's information for logging and auditing.
  • Date Validation:
    • Initializes currentDate to the current UTC date and time.
    • If a date is provided:
      • Tries to parse it into DateTime.
      • If parsing fails:
        • Logs an error: "user send invalid date"
        • Returns a 400 Bad Request with message "Invalid date."
  • Project Lookup:
    • Fetches the project using the provided projectId.
    • If the project is not found:
      • Logs the event with employee ID and date.
      • Returns a 404 Not Found response with message "Project not found".
  • Fetch Active Project Allocations:
    • Queries ProjectAllocations for active assignments to this project and tenant.
    • Extracts distinct EmployeeIds from the allocations.
  • Retrieve Employee Information:
    • Fetches employee records whose IDs match the list of assigned employees.
  • Fetch Attendance Records:
    • Queries the Attendes table for attendance entries:
      • Where EmployeeID is in the list
      • ProjectID matches the target project
      • InTime is not null
      • InTime.Date equals the selected date
  • Build Attendance View Models:
    • For each matching attendance record:
      • Finds the corresponding employee info.
      • Creates an EmployeeAttendanceVM with:
        • Employee name
        • InTime, OutTime, and Comment
        • Defaults InTime and OutTime to DateTime.UtcNow if missing (though logically they shouldn't be)
  • Construct Final Response Model:
    • Creates a ProjectAttendanceVM:
      • AttendanceTable: List of employee attendance VMs
      • CheckedInEmployee: Count of attendance records for the day
      • AssignedEmployee: Total employees assigned to the project
  • Logging and Response:
    • Logs the request with project ID, date, and employee ID.
    • Returns a 200 OK response with the assembled project attendance data.
- **Get Tenant and Employee Info**: - Retrieves the current tenant ID using _userHelper.GetTenantId(). - Retrieves the logged-in employee's information for logging and auditing. - **Date Validation**: - Initializes currentDate to the current UTC date and time. - If a date is provided: - Tries to parse it into DateTime. - If parsing fails: - Logs an error: "user send invalid date" - Returns a 400 Bad Request with message "Invalid date." - **Project Lookup**: - Fetches the project using the provided projectId. - If the project is not found: - Logs the event with employee ID and date. - Returns a 404 Not Found response with message "Project not found". - **Fetch Active Project Allocations**: - Queries ProjectAllocations for active assignments to this project and tenant. - Extracts distinct EmployeeIds from the allocations. - **Retrieve Employee Information**: - Fetches employee records whose IDs match the list of assigned employees. - **Fetch Attendance Records**: - Queries the Attendes table for attendance entries: - Where EmployeeID is in the list - ProjectID matches the target project - InTime is not null - InTime.Date equals the selected date - **Build Attendance View Models**: - For each matching attendance record: - Finds the corresponding employee info. - Creates an EmployeeAttendanceVM with: - Employee name - InTime, OutTime, and Comment - Defaults InTime and OutTime to DateTime.UtcNow if missing (though logically they shouldn't be) - **Construct Final Response Model**: - Creates a ProjectAttendanceVM: - AttendanceTable: List of employee attendance VMs - CheckedInEmployee: Count of attendance records for the day - AssignedEmployee: Total employees assigned to the project - **Logging and Response**: - Logs the request with project ID, date, and employee ID. - Returns a 200 OK response with the assembled project attendance data.
ashutosh.nehete added 1 commit 2025-05-24 04:44:35 +00:00
vikas.nale merged commit 52ee06d47e into Issue_May_4W 2025-05-24 04:58:06 +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#71
No description provided.