253 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			253 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Marco.Pms.Model.DocumentManager;
 | |
| using Marco.Pms.Model.Dtos.Forum;
 | |
| using Marco.Pms.Model.Dtos.Master;
 | |
| using Marco.Pms.Model.Employees;
 | |
| using Marco.Pms.Model.Forum;
 | |
| using Marco.Pms.Model.Master;
 | |
| using Marco.Pms.Model.ViewModels.Forum;
 | |
| 
 | |
| namespace Marco.Pms.Model.Mapper
 | |
| {
 | |
|     public static class ForumMapper
 | |
|     {
 | |
|         public static TicketForum ToTicketForumFromCreateTicketDto(this CreateTicketDto createTicketDto, Guid tenantId)
 | |
|         {
 | |
|             return new TicketForum
 | |
|             {
 | |
|                 Subject = createTicketDto.Subject,
 | |
|                 Description = createTicketDto.Description,
 | |
|                 StatusId = createTicketDto.StatusId,
 | |
|                 TypeId = createTicketDto.TypeId,
 | |
|                 CreatedById = createTicketDto.CreatedById,
 | |
|                 CreatedAt = createTicketDto.CreatedAt,
 | |
|                 LinkedProjectId = createTicketDto.LinkedProjectId,
 | |
|                 LinkedActivityId = createTicketDto.LinkedActivityId,
 | |
|                 PriorityId = createTicketDto.PriorityId,
 | |
|                 TenantId = tenantId,
 | |
|             };
 | |
|         }
 | |
|         public static TicketForum ToTicketForumFromUpdateTicketDto(this UpdateTicketDto updateTicketDto, TicketForum ticket)
 | |
|         {
 | |
|             return new TicketForum
 | |
|             {
 | |
|                 Id = updateTicketDto.Id,
 | |
|                 Subject = updateTicketDto.Subject,
 | |
|                 Description = updateTicketDto.Description,
 | |
|                 StatusId = updateTicketDto.StatusId,
 | |
|                 TypeId = updateTicketDto.TypeId,
 | |
|                 CreatedById = ticket.CreatedById,
 | |
|                 CreatedAt = ticket.CreatedAt,
 | |
|                 LinkedProjectId = ticket.LinkedProjectId,
 | |
|                 LinkedActivityId = ticket.LinkedActivityId,
 | |
|                 PriorityId = updateTicketDto.PriorityId,
 | |
|                 TenantId = ticket.TenantId
 | |
|             };
 | |
|         }
 | |
| 
 | |
|         public static TicketComment ToTicketCommentFromAddCommentDto(this AddCommentDto commentDto, Guid tenantId)
 | |
|         {
 | |
|             return new TicketComment
 | |
|             {
 | |
|                 TicketId = commentDto.TicketId,
 | |
|                 AuthorId = commentDto.AuthorId,
 | |
|                 MessageText = commentDto.MessageText,
 | |
|                 SentAt = commentDto.SentAt,
 | |
|                 ParentMessageId = commentDto.ParentMessageId,
 | |
|                 TenantId = tenantId,
 | |
|             };
 | |
|         }
 | |
|         public static TicketComment ToTicketCommentFromUpdateCommentDto(this UpdateCommentDto updateComment, Guid tenantId, TicketComment comment)
 | |
|         {
 | |
|             return new TicketComment
 | |
|             {
 | |
|                 Id = updateComment.Id,
 | |
|                 TicketId = updateComment.TicketId,
 | |
|                 AuthorId = comment.AuthorId,
 | |
|                 MessageText = updateComment.MessageText,
 | |
|                 SentAt = comment.SentAt,
 | |
|                 ParentMessageId = updateComment.ParentMessageId,
 | |
|                 TenantId = tenantId,
 | |
|             };
 | |
|         }
 | |
|         public static TicketAttachment ToTicketAttachmentFromForumAttachmentDto(this ForumAttachmentDto AttachmentDto, Guid ticketId, Guid fileId, Guid? commentId = null)
 | |
|         {
 | |
|             return new TicketAttachment
 | |
|             {
 | |
|                 TicketId = ticketId,
 | |
|                 CommentId = commentId,
 | |
|                 FileName = AttachmentDto.FileName,
 | |
|                 FileId = fileId,
 | |
|             };
 | |
|         }
 | |
|         public static TicketAttachment ToTicketAttachmentFromUpdateAttachmentDto(this UpdateAttachmentDto AttachmentDto, Guid ticketId, Guid fileId, Guid? commentId = null)
 | |
|         {
 | |
|             return new TicketAttachment
 | |
|             {
 | |
|                 TicketId = ticketId,
 | |
|                 CommentId = commentId,
 | |
|                 FileName = AttachmentDto.FileName,
 | |
|                 FileId = fileId,
 | |
|             };
 | |
|         }
 | |
| 
 | |
|         public static Document ToDocumentFromForumAttachmentDto(this ForumAttachmentDto AttachmentDto, string objectKey, string thumbS3Key, DateTime uploadedAt, Guid tenantId)
 | |
|         {
 | |
|             return new Document
 | |
|             {
 | |
|                 FileName = AttachmentDto.FileName,
 | |
|                 ContentType = AttachmentDto.ContentType,
 | |
|                 S3Key = objectKey,
 | |
|                 ThumbS3Key = thumbS3Key,
 | |
|                 Base64Data = AttachmentDto.Base64Data,
 | |
|                 FileSize = AttachmentDto.FileSize,
 | |
|                 UploadedAt = uploadedAt,
 | |
|                 TenantId = tenantId
 | |
|             };
 | |
|         }
 | |
|         public static Document ToDocumentFromUpdateAttachmentDto(this UpdateAttachmentDto AttachmentDto, string objectKey, string thumbS3Key, DateTime uploadedAt, Guid tenantId)
 | |
|         {
 | |
|             return new Document
 | |
|             {
 | |
|                 FileName = AttachmentDto.FileName,
 | |
|                 ContentType = AttachmentDto.ContentType,
 | |
|                 S3Key = objectKey,
 | |
|                 ThumbS3Key = thumbS3Key,
 | |
|                 Base64Data = AttachmentDto.Base64Data,
 | |
|                 FileSize = AttachmentDto.FileSize,
 | |
|                 UploadedAt = uploadedAt,
 | |
|                 TenantId = tenantId
 | |
|             };
 | |
|         }
 | |
|         public static ForumTicketVM ToForumTicketVMFromTicketForum(this TicketForum ticket, Employee employee)
 | |
|         {
 | |
|             return new ForumTicketVM
 | |
|             {
 | |
|                 Id = ticket.Id,
 | |
|                 Subject = ticket.Subject,
 | |
|                 Description = ticket.Description,
 | |
|                 CreatedAt = ticket.CreatedAt,
 | |
|                 LinkedProjectId = ticket.LinkedProjectId,
 | |
|                 LinkedActivityId = ticket.LinkedActivityId,
 | |
|                 Status = ticket.TicketStatusMaster != null ? ticket.TicketStatusMaster.ToTicketStatusVMFromTicketStatusMaster() : new TicketStatusVM(),
 | |
|                 Priority = ticket.Priority != null ? ticket.Priority.ToTicketPriorityVMFromTicketPriorityMaster() : new TicketPriorityVM(),
 | |
|                 Type = ticket.TicketTypeMaster != null ? ticket.TicketTypeMaster.ToTicketTypeVMFromTicketTypeMaster() : new TicketTypeVM(),
 | |
|                 CreatedBy = employee.ToBasicEmployeeVMFromEmployee(),
 | |
|             };
 | |
|         }
 | |
|         public static TicketAttachmentVM ToTicketAttachmentVMFromTicketAttachment(this TicketAttachment attachment, string preSignedUrl, string thumbPreSignedUrl)
 | |
|         {
 | |
|             return new TicketAttachmentVM
 | |
|             {
 | |
|                 Id = attachment.Id,
 | |
|                 TicketId = attachment.TicketId,
 | |
|                 CommentId = attachment.CommentId,
 | |
|                 FileName = attachment.FileName,
 | |
|                 PreSignedUrl = preSignedUrl,
 | |
|                 ThumbPreSignedUrl = thumbPreSignedUrl
 | |
|             };
 | |
|         }
 | |
|         public static TicketCommentVM ToTicketCommentVMFromTicketComment(this TicketComment comment, Employee employee)
 | |
|         {
 | |
|             return new TicketCommentVM
 | |
|             {
 | |
|                 Id = comment.Id,
 | |
|                 TicketId = comment.TicketId,
 | |
|                 Author = employee.ToBasicEmployeeVMFromEmployee(),
 | |
|                 MessageText = comment.MessageText,
 | |
|                 SentAt = comment.SentAt,
 | |
|                 ParentMessageId = comment.ParentMessageId,
 | |
|                 Attachments = new List<TicketAttachmentVM>()
 | |
|             };
 | |
|         }
 | |
|         public static TicketStatusVM ToTicketStatusVMFromTicketStatusMaster(this TicketStatusMaster statusMaster)
 | |
|         {
 | |
|             return new TicketStatusVM
 | |
|             {
 | |
|                 Id = statusMaster.Id,
 | |
|                 Name = statusMaster.Name,
 | |
|                 Description = statusMaster.Description,
 | |
|                 ColorCode = statusMaster.ColorCode,
 | |
|                 IsDefault = statusMaster.IsDefault
 | |
|             };
 | |
|         }
 | |
|         public static TicketStatusMaster ToTicketStatusMasterFromTicketStatusMasterDto(this TicketStatusMasterDto statusMasterDto, Guid tenantId)
 | |
|         {
 | |
|             return new TicketStatusMaster
 | |
|             {
 | |
|                 Id = statusMasterDto.Id != null ? statusMasterDto.Id.Value : Guid.Empty,
 | |
|                 Name = statusMasterDto.Name,
 | |
|                 Description = statusMasterDto.Description,
 | |
|                 ColorCode = statusMasterDto.ColorCode,
 | |
|                 IsDefault = statusMasterDto.IsDefault,
 | |
|                 TenantId = tenantId
 | |
| 
 | |
|             };
 | |
|         }
 | |
|         public static TicketPriorityVM ToTicketPriorityVMFromTicketPriorityMaster(this TicketPriorityMaster priorityMaster)
 | |
|         {
 | |
|             return new TicketPriorityVM
 | |
|             {
 | |
|                 Id = priorityMaster.Id,
 | |
|                 Name = priorityMaster.Name,
 | |
|                 Level = priorityMaster.Level,
 | |
|                 ColorCode = priorityMaster.ColorCode,
 | |
|                 IsDefault = priorityMaster.IsDefault
 | |
|             };
 | |
|         }
 | |
|         public static TicketPriorityMaster ToTicketPriorityMasterFromTicketPriorityMasterDto(this TicketPriorityMasterDto priorityMasterDto, Guid tenantId)
 | |
|         {
 | |
|             return new TicketPriorityMaster
 | |
|             {
 | |
|                 Id = priorityMasterDto.Id != null ? priorityMasterDto.Id.Value : Guid.Empty,
 | |
|                 Name = priorityMasterDto.Name,
 | |
|                 Level = priorityMasterDto.Level,
 | |
|                 ColorCode = priorityMasterDto.ColorCode,
 | |
|                 IsDefault = priorityMasterDto.IsDefault,
 | |
|                 TenantId = tenantId
 | |
|             };
 | |
|         }
 | |
|         public static TicketTypeVM ToTicketTypeVMFromTicketTypeMaster(this TicketTypeMaster typeMaster)
 | |
|         {
 | |
|             return new TicketTypeVM
 | |
|             {
 | |
|                 Id = typeMaster.Id,
 | |
|                 Name = typeMaster.Name,
 | |
|                 Description = typeMaster.Description,
 | |
|                 IsDefault = typeMaster.IsDefault
 | |
|             };
 | |
|         }
 | |
|         public static TicketTypeMaster ToTicketTypeMasterFromTicketTypeMasterDto(this TicketTypeMasterDto typeMasterDto, Guid tenantId)
 | |
|         {
 | |
|             return new TicketTypeMaster
 | |
|             {
 | |
|                 Id = typeMasterDto.Id != null ? typeMasterDto.Id.Value : Guid.Empty,
 | |
|                 Name = typeMasterDto.Name,
 | |
|                 Description = typeMasterDto.Description,
 | |
|                 IsDefault = typeMasterDto.IsDefault,
 | |
|                 TenantId = tenantId
 | |
|             };
 | |
|         }
 | |
|         public static TicketTagVM ToTicketTagVMFromTicketTagMaster(this TicketTagMaster tagMaster)
 | |
|         {
 | |
|             return new TicketTagVM
 | |
|             {
 | |
|                 Id = tagMaster.Id,
 | |
|                 Name = tagMaster.Name,
 | |
|                 ColorCode = tagMaster.ColorCode,
 | |
|                 IsDefault = tagMaster.IsDefault
 | |
|             };
 | |
|         }
 | |
|         public static TicketTagMaster ToTicketTagMasterFromTicketTagMasterDto(this TicketTagMasterDto tagMasterDto, Guid tenantId)
 | |
|         {
 | |
|             return new TicketTagMaster
 | |
|             {
 | |
|                 Id = tagMasterDto.Id != null ? tagMasterDto.Id.Value : Guid.Empty,
 | |
|                 Name = tagMasterDto.Name,
 | |
|                 ColorCode = tagMasterDto.ColorCode,
 | |
|                 IsDefault = tagMasterDto.IsDefault,
 | |
|                 TenantId = tenantId
 | |
|             };
 | |
|         }
 | |
|     }
 | |
| }
 |