import { TimeTrackingSetting, TimeTrackingSettingForCreation } from '../../business/models/timeTrackingSetting';
import { TimeTrackingSettingDAO } from '../dataAccessObjects/setting';

export const mapSettingDAOToModel = (entityDAO: TimeTrackingSettingDAO): TimeTrackingSetting => {
    return {
        id: entityDAO.id,
        instanceId: entityDAO.instanceId,
        nightShiftAssignment: entityDAO.nightShiftAssignment,
    };
};

export const mapSettingModelToDAO = (entity: TimeTrackingSetting | TimeTrackingSettingForCreation): TimeTrackingSettingDAO => {
    const entityDAO = new TimeTrackingSettingDAO({
        instanceId: entity.instanceId,
        nightShiftAssignment: entity.nightShiftAssignment,
    });
    if (entity instanceof TimeTrackingSetting) {
        entityDAO.id = entity.id;
        entityDAO.isNewRecord = false;
    }
    return entityDAO;
};
