fromEntity static method

Future<AssignmentModel?> fromEntity(
  1. String documentID,
  2. AssignmentEntity? entity
)

Implementation

static Future<AssignmentModel?> fromEntity(
    String documentID, AssignmentEntity? entity) async {
  if (entity == null) return null;
  var counter = 0;
  return AssignmentModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    reporterId: entity.reporterId ?? '',
    assigneeId: entity.assigneeId,
    task: TaskModel.fromEntity(entity.task),
    workflowTaskSeqNumber: entity.workflowTaskSeqNumber,
    timestamp: entity.timestamp == null
        ? null
        : DateTime.fromMillisecondsSinceEpoch((entity.timestamp as int)),
    status: toAssignmentStatus(entity.status),
    resultsCurrent: entity.resultsCurrent == null
        ? null
        : List<AssignmentResultModel>.from(
            await Future.wait(entity.resultsCurrent!.map((item) {
            counter++;
            return AssignmentResultModel.fromEntity(counter.toString(), item);
          }).toList())),
    resultsPrevious: entity.resultsPrevious == null
        ? null
        : List<AssignmentResultModel>.from(
            await Future.wait(entity.resultsPrevious!.map((item) {
            counter++;
            return AssignmentResultModel.fromEntity(counter.toString(), item);
          }).toList())),
    triggeredById: entity.triggeredById,
    confirmMessage:
        await WorkflowNotificationModel.fromEntity(entity.confirmMessage),
    rejectMessage:
        await WorkflowNotificationModel.fromEntity(entity.rejectMessage),
  );
}