public async Task <bool> AttachmentToPost(PostAttachmentViewModel postAttachment)
        {
            var post = await _publicContext.Post.FirstOrDefaultAsync(x => x.Id == postAttachment.PostId);

            if (post == null)
            {
                ExceptionFactory.SoftException(ExceptionEnum.CommentNotFound, "Comment not found");
            }

            if (!await _publicContext.Attachment.AnyAsync(x => x.Id == postAttachment.AttachmentId))
            {
                ExceptionFactory.SoftException(ExceptionEnum.AttachmentNotFound,
                                               $"Attachment {postAttachment.AttachmentId} not found");
            }

            var attachmentToPost = new AttachmentPost()
            {
                AttachmentId = postAttachment.AttachmentId,
                PostId       = postAttachment.PostId,
            };

            await _publicContext.AttachmentPost.AddAsync(attachmentToPost);

            await _publicContext.SaveChangesAsync();

            return(true);
        }
        private async Task AttachFileToPost(int postId, int attachmentId)
        {
            if (await _context.Attachment.AnyAsync(x => x.Id == attachmentId))
            {
                var attachmentPost = new AttachmentPost
                {
                    AttachmentId = attachmentId, PostId = postId
                };

                await _context.AttachmentPost.AddAsync(attachmentPost);
            }
        }