marco.pms.api/Marco.Pms.Model/Mapper/ActivitiesMapper.cs

171 lines
6.9 KiB
C#

using Marco.Pms.Model.Activities;
using Marco.Pms.Model.Dtos.Activities;
using Marco.Pms.Model.Entitlements;
using Marco.Pms.Model.ViewModels.Activities;
#nullable disable
namespace Marco.Pms.Model.Mapper
{
public static class ActivitiesMapper
{
public static TaskAllocation ToTaskAllocationFromAssignTaskDto(this AssignTaskDto assignTask, int EmployeeId,int 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, int tenantId, int EmployeeId)
{
return new TaskComment
{
TaskAllocationId = reportTask.Id,
CommentDate = reportTask.ReportedDate,
Comment = reportTask.Comment,
CommentedBy = EmployeeId,
TenantId = tenantId
};
}
public static TaskComment ToCommentFromCommentDto(this CreateCommentDto createComment, int tenantId, int EmployeeId) {
return new TaskComment {
TaskAllocationId = createComment.TaskAllocationId,
CommentDate = createComment.CommentDate,
Comment = createComment.Comment,
CommentedBy = EmployeeId,
TenantId = tenantId
};
}
public static TaskVM TaskAllocationToTaskVM(this TaskAllocation taskAllocation,string employeeName,string tenant )
{
return new TaskVM
{
Id = taskAllocation.Id,
AssignmentDate = taskAllocation.AssignmentDate,
PlannedTask = taskAllocation.PlannedTask,
CompletedTask = taskAllocation.CompletedTask,
ReportedDate = taskAllocation.ReportedDate,
Description = taskAllocation.Description,
AssignBy = employeeName,
Tenant = tenant,
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.ToEmployeeVMFromEmployee(),
WorkItemId = taskAllocation.WorkItemId,
TenantId = taskAllocation.TenantId
};
}
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,
TenantId = taskAllocation.TenantId
};
}
public static ActivityMaster ToActivityMasterFromCreateActivityMasterDto(this CreateActivityMasterDto createActivity,int 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,
CompletedTask = taskAllocation.CompletedTask,
AssignedBy = taskAllocation.Employee.ToBasicEmployeeVMFromEmployee(),
WorkItemId = taskAllocation.WorkItemId,
WorkItem = taskAllocation.WorkItem,
TenantId = taskAllocation.TenantId,
//CheckList =
};
}
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.ToBasicEmployeeVMFromEmployee()
};
}
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,int 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,int tenantId,int activityId)
{
return new ActivityCheckList
{
Id = checkListDto.Id,
Description = checkListDto.Description,
ActivityId = activityId,
IsMandatory = checkListDto.IsMandatory,
TenantId = tenantId
};
}
public static CheckListVM ToCheckListVMFromReportCheckListDto(this ReportCheckListDto checkListDto, int activityId)
{
return new CheckListVM
{
Id = checkListDto.Id,
Description = checkListDto.Description,
ActivityId = activityId,
IsChecked = checkListDto.IsChecked,
IsMandatory = checkListDto.IsMandatory,
};
}
}
}