import { TimeTrackingFaceAssignment, TimeTrackingFaceAssignmentForCreation } from '../../../business/models/timeTracking/timeTrackingFaceAssignments';
import { TimeTrackingFaceAssignmentDAO } from '../../dataAccessObjects/timeTracking/timeTrackingFaceAssignment';

export const mapTimeTrackingFaceAssignmentDAOToModel = (timeTrackingFaceAssignment: TimeTrackingFaceAssignmentDAO): TimeTrackingFaceAssignment => {
    return new TimeTrackingFaceAssignment({
        faceId: timeTrackingFaceAssignment.faceId,
        id: timeTrackingFaceAssignment.id,
        instanceId: timeTrackingFaceAssignment.instanceId,
        referenceImage: timeTrackingFaceAssignment.referenceImage,
        regionId: timeTrackingFaceAssignment.regionId,
        siteId: timeTrackingFaceAssignment.siteId,
        source: timeTrackingFaceAssignment.source,
        userId: timeTrackingFaceAssignment.userId,
    });
};

export const mapTimeTrackingFaceAssignmentModelToDAO = (
    timeTrackingFaceAssignment: TimeTrackingFaceAssignment | TimeTrackingFaceAssignmentForCreation,
): TimeTrackingFaceAssignmentDAO => {
    const timeTrackingFaceAssignmentDAO = new TimeTrackingFaceAssignmentDAO({
        faceId: timeTrackingFaceAssignment.faceId,
        instanceId: timeTrackingFaceAssignment.instanceId,
        referenceImage: timeTrackingFaceAssignment.referenceImage,
        regionId: timeTrackingFaceAssignment.regionId,
        siteId: timeTrackingFaceAssignment.siteId,
        source: timeTrackingFaceAssignment.source,
        userId: timeTrackingFaceAssignment.userId,
    });
    if (timeTrackingFaceAssignment instanceof TimeTrackingFaceAssignment) {
        timeTrackingFaceAssignmentDAO.id = timeTrackingFaceAssignment.id;
        timeTrackingFaceAssignmentDAO.isNewRecord = false;
    }
    return timeTrackingFaceAssignmentDAO;
};
