fetchRegisters method

dynamic fetchRegisters({
  1. required int offSet,
  2. required int limit,
})

Implementation

fetchRegisters({required int offSet, required int limit}) async {
  final registers = await attendanceDataRepository?.search(
    AttendanceRegisterSearchModel(
      limit: limit,
      offSet: offSet,
      staffId: AttendanceSingleton().loggedInIndividualId,
      referenceId: AttendanceSingleton().projectId,
    ),
  );

  if (registers != null) {
    final List<AttendanceRegisterModel> attendanceRegisters =
        await Future.wait(registers.map((e) async {
      final registerCompletedLogs = await attendanceLogDataRepository?.search(
        AttendanceLogSearchModel(
          registerId: e.id,
          uploadToServer: true,
        ),
      );

      return _processAttendanceRegister(e, registerCompletedLogs);
    }));

    return attendanceRegisters;
  } else {
    return [];
  }
}