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.ToEmployeeVMFromEmployee(), WorkItemId = taskAllocation.WorkItemId, WorkItem = taskAllocation.WorkItem, TenantId = taskAllocation.TenantId }; } 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.ToEmployeeVMFromEmployee() }; } public static ActivityVM ToActivityVMFromActivityMaster(this ActivityMaster activity,List checkList) { return new ActivityVM { Id = activity.Id, ActivityName = activity.ActivityName, UnitOfMeasurement = activity.UnitOfMeasurement, CheckLists = checkList, }; } public static CheckListVM ToCheckListVMFromActivityCheckList(this ActivityCheckList checkList,int activityId) { return new CheckListVM { Id = checkList.Id, Check = checkList.Check, ActivityMasterId = activityId, IsChecked = checkList.IsChecked, IsMandatory = checkList.IsMandatory, }; } public static ActivityCheckList ToActivityCheckListFromCreateCheckListDto(this CreateCheckListDto checkListDto,int tenantId) { return new ActivityCheckList { Id = checkListDto.Id, Check = checkListDto.Check, IsMandatory = checkListDto.IsMandatory, TenantId = tenantId }; } } }