using Marco.Pms.Model.DocumentManager; using Marco.Pms.Model.Dtos.Forum; using Marco.Pms.Model.Employees; using Marco.Pms.Model.Forum; using Marco.Pms.Model.ViewModels.Forum; namespace Marco.Pms.Model.Mapper { public static class ForumMapper { public static TicketForum ToTicketForumFromCreateTicketDto(this CreateTicketDto createTicketDto) { return new TicketForum { Subject = createTicketDto.Subject, Description = createTicketDto.Description, StatusId = createTicketDto.StatusId, TypeId = createTicketDto.TypeId, CreatedById = createTicketDto.CreatedById, CreatedAt = createTicketDto.CreatedAt, LinkedActivityId = createTicketDto.LinkedActivityId, PriorityId = createTicketDto.PriorityId, TenantId = createTicketDto.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, LinkedActivityId = updateTicketDto.LinkedActivityId, PriorityId = updateTicketDto.PriorityId, TenantId = ticket.TenantId }; } public static TicketComment ToTicketCommentFromAddCommentDto(this AddCommentDto commentDto) { return new TicketComment { TicketId = commentDto.TicketId, AuthorId = commentDto.AuthorId, MessageText = commentDto.MessageText, SentAt = commentDto.SentAt, ParentMessageId = commentDto.ParentMessageId, TenantId = commentDto.TenantId, }; } public static TicketComment ToTicketCommentFromUpdateCommentDto(this UpdateCommentDto updateComment, int 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 Document ToDocumentFromForumAttachmentDto(this ForumAttachmentDto AttachmentDto, string objectKey, string thumbS3Key, DateTime uploadedAt, int 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, LinkedActivityId = ticket.LinkedActivityId, Status = ticket.TicketStatusMaster.ToTicketStatusVMFromTicketStatusMaster(), Priority = ticket.Priority.ToTicketPriorityVMFromTicketPriorityMaster(), Type = ticket.TicketTypeMaster.ToTicketTypeVMFromTicketTypeMaster(), 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() }; } 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 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 TicketTypeVM ToTicketTypeVMFromTicketTypeMaster(this TicketTypeMaster typeMaster) { return new TicketTypeVM { Id = typeMaster.Id, Name = typeMaster.Name, Description = typeMaster.Description, IsDefault = typeMaster.IsDefault }; } public static TicketTagVM ToTicketTagVMFromTicketTagMaster(this TicketTagMaster tagMaster) { return new TicketTagVM { Id = tagMaster.Id, Name = tagMaster.Name, ColorCode = tagMaster.ColorCode, IsDefault = tagMaster.IsDefault }; } } }