170 lines
7.1 KiB
C#
170 lines
7.1 KiB
C#
using Marco.Pms.Model.Activities;
|
|
using Marco.Pms.Model.Dtos.Activities;
|
|
using Marco.Pms.Model.Entitlements;
|
|
using Marco.Pms.Model.Master;
|
|
using Marco.Pms.Model.ViewModels.Activities;
|
|
|
|
namespace Marco.Pms.Model.Mapper
|
|
{
|
|
public static class ActivitiesMapper
|
|
{
|
|
public static TaskAllocation ToTaskAllocationFromAssignTaskDto(this AssignTaskDto assignTask, Guid EmployeeId, Guid tenantId)
|
|
{
|
|
return new TaskAllocation
|
|
{
|
|
AssignmentDate = assignTask.AssignmentDate,
|
|
PlannedTask = assignTask.PlannedTask,
|
|
CompletedTask = 0,
|
|
Description = assignTask.Description,
|
|
AssignedBy = EmployeeId,
|
|
WorkItemId = assignTask.WorkItemId,
|
|
TenantId = tenantId
|
|
};
|
|
}
|
|
public static TaskComment ToCommentFromReportTaskDto(this ReportTaskDto reportTask, Guid tenantId, Guid EmployeeId)
|
|
{
|
|
return new TaskComment
|
|
{
|
|
TaskAllocationId = reportTask.Id,
|
|
CommentDate = reportTask.ReportedDate,
|
|
Comment = reportTask.Comment ?? string.Empty,
|
|
CommentedBy = EmployeeId,
|
|
TenantId = tenantId
|
|
};
|
|
}
|
|
public static TaskComment ToCommentFromCommentDto(this CreateCommentDto createComment, Guid tenantId, Guid EmployeeId)
|
|
{
|
|
return new TaskComment
|
|
{
|
|
TaskAllocationId = createComment.TaskAllocationId,
|
|
CommentDate = createComment.CommentDate,
|
|
Comment = createComment.Comment ?? string.Empty,
|
|
CommentedBy = EmployeeId,
|
|
TenantId = tenantId
|
|
};
|
|
}
|
|
public static TaskVM TaskAllocationToTaskVM(this TaskAllocation taskAllocation, string employeeName)
|
|
{
|
|
return new TaskVM
|
|
{
|
|
Id = taskAllocation.Id,
|
|
AssignmentDate = taskAllocation.AssignmentDate,
|
|
PlannedTask = taskAllocation.PlannedTask,
|
|
CompletedTask = taskAllocation.CompletedTask,
|
|
ReportedDate = taskAllocation.ReportedDate,
|
|
Description = taskAllocation.Description,
|
|
AssignBy = employeeName,
|
|
WorkItem = taskAllocation.WorkItem
|
|
};
|
|
}
|
|
public static AssignedTaskVM ToAssignTaskVMFromTaskAllocation(this TaskAllocation taskAllocation)
|
|
{
|
|
return new AssignedTaskVM
|
|
{
|
|
Id = taskAllocation.Id,
|
|
AssignmentDate = taskAllocation.AssignmentDate,
|
|
PlannedTask = taskAllocation.PlannedTask,
|
|
CompletedTask = taskAllocation.CompletedTask,
|
|
ReportedDate = taskAllocation.ReportedDate,
|
|
Description = taskAllocation.Description,
|
|
AssignedBy = taskAllocation.Employee != null ? taskAllocation.Employee.ToEmployeeVMFromEmployee() : new ViewModels.Employee.EmployeeVM(),
|
|
WorkItemId = taskAllocation.WorkItemId
|
|
};
|
|
}
|
|
public static ReportTaskVM ToReportTaskVMFromTaskAllocation(this TaskAllocation taskAllocation)
|
|
{
|
|
return new ReportTaskVM
|
|
{
|
|
Id = taskAllocation.Id,
|
|
AssignmentDate = taskAllocation.AssignmentDate,
|
|
PlannedTask = taskAllocation.PlannedTask,
|
|
CompletedTask = taskAllocation.CompletedTask,
|
|
ReportedDate = taskAllocation.ReportedDate,
|
|
Description = taskAllocation.Description,
|
|
AssignedBy = taskAllocation.AssignedBy,
|
|
WorkItemId = taskAllocation.WorkItemId
|
|
};
|
|
}
|
|
public static ActivityMaster ToActivityMasterFromCreateActivityMasterDto(this CreateActivityMasterDto createActivity, Guid tenantId)
|
|
{
|
|
return new ActivityMaster
|
|
{
|
|
ActivityName = createActivity.ActivityName,
|
|
UnitOfMeasurement = createActivity.UnitOfMeasurement,
|
|
TenantId = tenantId
|
|
};
|
|
}
|
|
|
|
public static ListTaskVM ToListTaskVMFromTaskAllocation(this TaskAllocation taskAllocation)
|
|
{
|
|
return new ListTaskVM
|
|
{
|
|
Id = taskAllocation.Id,
|
|
AssignmentDate = taskAllocation.AssignmentDate,
|
|
PlannedTask = taskAllocation.PlannedTask,
|
|
ReportedDate = taskAllocation.ReportedDate,
|
|
CompletedTask = taskAllocation.CompletedTask,
|
|
AssignedBy = taskAllocation.Employee != null ? taskAllocation.Employee.ToBasicEmployeeVMFromEmployee() : new BasicEmployeeVM(),
|
|
WorkItemId = taskAllocation.WorkItemId,
|
|
WorkItem = taskAllocation.WorkItem
|
|
};
|
|
}
|
|
public static CommentVM ToCommentVMFromTaskComment(this TaskComment comment)
|
|
{
|
|
return new CommentVM
|
|
{
|
|
Id = comment.Id,
|
|
TaskAllocationId = comment.TaskAllocationId,
|
|
CommentDate = comment.CommentDate,
|
|
Comment = comment.Comment,
|
|
CommentedBy = comment.CommentedBy,
|
|
Employee = comment.Employee != null ? comment.Employee.ToBasicEmployeeVMFromEmployee() : new BasicEmployeeVM()
|
|
};
|
|
}
|
|
|
|
public static ActivityVM ToActivityVMFromActivityMaster(this ActivityMaster activity, List<CheckListVM> checkList)
|
|
{
|
|
return new ActivityVM
|
|
{
|
|
Id = activity.Id,
|
|
ActivityName = activity.ActivityName,
|
|
UnitOfMeasurement = activity.UnitOfMeasurement,
|
|
CheckLists = checkList,
|
|
};
|
|
}
|
|
public static CheckListVM ToCheckListVMFromActivityCheckList(this ActivityCheckList checkList, Guid activityId, bool IsChecked)
|
|
{
|
|
return new CheckListVM
|
|
{
|
|
Id = checkList.Id,
|
|
Description = checkList.Description,
|
|
ActivityId = activityId,
|
|
IsChecked = IsChecked,
|
|
IsMandatory = checkList.IsMandatory,
|
|
};
|
|
}
|
|
public static ActivityCheckList ToActivityCheckListFromCreateCheckListDto(this CreateCheckListDto checkListDto, Guid tenantId, Guid activityId)
|
|
{
|
|
return new ActivityCheckList
|
|
{
|
|
Id = checkListDto.Id != null ? checkListDto.Id.Value : Guid.Empty,
|
|
Description = checkListDto.Description,
|
|
ActivityId = activityId,
|
|
IsMandatory = checkListDto.IsMandatory,
|
|
TenantId = tenantId
|
|
};
|
|
}
|
|
public static CheckListVM ToCheckListVMFromReportCheckListDto(this ReportCheckListDto checkListDto, Guid activityId)
|
|
{
|
|
return new CheckListVM
|
|
{
|
|
Id = checkListDto.Id,
|
|
Description = checkListDto.Description,
|
|
ActivityId = activityId,
|
|
IsChecked = checkListDto.IsChecked,
|
|
IsMandatory = checkListDto.IsMandatory,
|
|
};
|
|
}
|
|
}
|
|
}
|