import { TimeTrackingKioskLink } from '../../business/models/timeTrackingKioskLink';
import { TimeTrackingKioskLinkDAO } from '../dataAccessObjects/kioskLink';

export const mapKioskLinkDAOToModel = (linkDAO: TimeTrackingKioskLinkDAO): TimeTrackingKioskLink => {
    return {
        id: linkDAO.id,
        code: linkDAO.code,
        instanceId: linkDAO.instanceId,
        kioskId: linkDAO.kioskId,
        expirationDate: linkDAO.expirationDate,
        expirationInMinutes: linkDAO.expirationInMinutes,
        status: linkDAO.status,
    };
};

export const mapKioskLinkModelToDAO = (link: TimeTrackingKioskLink): TimeTrackingKioskLinkDAO => {
    const linkDAO = new TimeTrackingKioskLinkDAO({
        code: link.code,
        instanceId: link.instanceId,
        kioskId: link.kioskId,
        expirationDate: link.expirationDate,
        expirationInMinutes: link.expirationInMinutes,
        status: link.status,
    });
    if (link.id) {
        linkDAO.id = link.id;
        linkDAO.isNewRecord = false;
    }
    return linkDAO;
};
