using Marco.Pms.Model.Activities; using Marco.Pms.Model.Dtos.Activities; using Marco.Pms.Model.Entitlements; using Marco.Pms.Model.ViewModels.Activities; using Microsoft.Extensions.DependencyModel; 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 }; } } }