checkResponse method
dynamic
checkResponse(
- List<
AttendanceLogModel> logResponse, - List<
AttendeeModel> attendees, - AttendanceIndividualLogSearchEvent event
Implementation
checkResponse(
List<AttendanceLogModel> logResponse,
List<AttendeeModel> attendees,
AttendanceIndividualLogSearchEvent event) async {
bool anyLogPresent = false;
final currentDate = DateTime.fromMillisecondsSinceEpoch(event.currentDate);
int twelvePM =
DateTime(currentDate.year, currentDate.month, currentDate.day, 11, 58)
.millisecondsSinceEpoch;
attendees = event.attendees.map((e) {
final entryLogList = logResponse
.where((l) =>
l.individualId == e.individualId &&
l.type == EnumValues.entry.toValue() &&
l.time == event.entryTime)
.toList();
final exitLogList = logResponse
.where((l) =>
l.individualId == e.individualId &&
l.type == EnumValues.exit.toValue() &&
(l.time == event.exitTime ||
l.time == event.entryTime ||
(event.isSingleSession && l.time == twelvePM)))
.toList();
entryLogList.any((entry) => entry.uploadToServer == true);
anyLogPresent = logResponse
.where((l) =>
(l.time == event.entryTime || l.time == event.exitTime) &&
l.registerId == e.registerId)
.toList()
.any((log) => log.uploadToServer == true);
return e.copyWith(
status: ((entryLogList.isEmpty || exitLogList.isEmpty) &&
anyLogPresent != true)
? -1
: (entryLogList.isNotEmpty &&
exitLogList.isNotEmpty &&
entryLogList.last.status == 'INACTIVE') ||
((entryLogList.isEmpty || exitLogList.isEmpty) &&
anyLogPresent == true)
? 0
: (entryLogList.isNotEmpty &&
exitLogList.isNotEmpty &&
event.isSingleSession == true &&
exitLogList.last.time == twelvePM)
? 0.5
: 1);
}).toList();
emit(AttendanceIndividualState.loaded(
attendanceCollectionModel: attendees, viewOnly: anyLogPresent));
}