49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import {Task} from "./task.model";
|
|
import {TaskDto} from "../../../api/dto/task/task.dto";
|
|
import {LocationMapper} from "../../location/location.mapper";
|
|
import {AttachmentMapper} from "../../attachment/attachment.mapper";
|
|
import {Priority} from './priority.model';
|
|
|
|
export class TaskMapper {
|
|
public static map(dto: TaskDto): Task {
|
|
if (dto == null) {
|
|
return null;
|
|
}
|
|
return new Task(
|
|
dto.id,
|
|
dto.createdAt,
|
|
dto.editedLastAt,
|
|
dto.ownerId,
|
|
dto.folderId,
|
|
dto.title,
|
|
dto.description,
|
|
LocationMapper.map(dto.location),
|
|
Priority.valueOf(dto.priority),
|
|
dto.state,
|
|
dto.startAt,
|
|
dto.dueAt,
|
|
dto.attachmentViewMode,
|
|
AttachmentMapper.map(dto.attachments)
|
|
);
|
|
}
|
|
|
|
public static unmap(task: Task): TaskDto {
|
|
return new TaskDto(
|
|
task.id,
|
|
task.createdAt,
|
|
task.editedLastAt,
|
|
task.ownerId,
|
|
task.folderId,
|
|
task.title,
|
|
task.description,
|
|
LocationMapper.unmap(task.location),
|
|
task.priority.name,
|
|
task.state,
|
|
task.startAt,
|
|
task.dueAt,
|
|
task.attachmentViewMode,
|
|
AttachmentMapper.unmap(task.attachments)
|
|
);
|
|
}
|
|
}
|