feat: add FileUploadDto and image file handling to CreateManualPayment command and protobuf definitions
Build and Deploy / build (push) Successful in 2m23s
Build and Deploy / build (push) Successful in 2m23s
This commit is contained in:
+12
@@ -8,6 +8,18 @@ public class CreateManualPaymentCommand : IRequest<CreateManualPaymentResponseDt
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string? ReferenceNumber { get; set; }
|
||||
public string? ImagePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Image file data for FMS upload
|
||||
/// </summary>
|
||||
public FileUploadDto? ImageFile { get; set; }
|
||||
}
|
||||
|
||||
public class FileUploadDto
|
||||
{
|
||||
public byte[] File { get; set; } = Array.Empty<byte>();
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Mime { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class CreateManualPaymentResponseDto
|
||||
|
||||
+20
-1
@@ -1,4 +1,5 @@
|
||||
using CMSMicroservice.Protobuf.Protos.ManualPayment;
|
||||
using Google.Protobuf;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BackOffice.BFF.Application.ManualPaymentCQ.Commands.CreateManualPayment;
|
||||
@@ -37,7 +38,25 @@ public class CreateManualPaymentCommandHandler : IRequestHandler<CreateManualPay
|
||||
grpcRequest.ReferenceNumber = request.ReferenceNumber;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.ImagePath))
|
||||
// Upload image to FMS if provided
|
||||
if (request.ImageFile != null && request.ImageFile.File != null && request.ImageFile.File.Length > 0)
|
||||
{
|
||||
var fileInfo = await _context.FileInfos.CreateNewFileInfoAsync(new()
|
||||
{
|
||||
Directory = "Images/ManualPayments",
|
||||
IsBase64 = false,
|
||||
MIME = request.ImageFile.Mime,
|
||||
FileName = request.ImageFile.FileName,
|
||||
File = ByteString.CopyFrom(request.ImageFile.File)
|
||||
}, cancellationToken: cancellationToken);
|
||||
|
||||
if (fileInfo != null && !string.IsNullOrWhiteSpace(fileInfo.File))
|
||||
{
|
||||
grpcRequest.ImagePath = fileInfo.File;
|
||||
_logger.LogInformation("Image uploaded to FMS: {ImagePath}", fileInfo.File);
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(request.ImagePath))
|
||||
{
|
||||
grpcRequest.ImagePath = request.ImagePath;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user