Added the file meta-data of file in details and get version API

This commit is contained in:
ashutosh.nehete 2025-09-03 18:01:07 +05:30
parent 0916abe464
commit 35ea41d1ce
3 changed files with 13 additions and 1 deletions

View File

@ -7,8 +7,9 @@ namespace Marco.Pms.Model.ViewModels.DocumentManager
public Guid Id { get; set; } public Guid Id { get; set; }
public string? Name { get; set; } public string? Name { get; set; }
public string? DocumentId { get; set; } public string? DocumentId { get; set; }
public string? PreSignedUrl { get; set; }
public int Version { get; set; } public int Version { get; set; }
public long FileSize { get; set; }
public string? ContentType { get; set; }
public DateTime UploadedAt { get; set; } public DateTime UploadedAt { get; set; }
public BasicEmployeeVM? UploadedBy { get; set; } public BasicEmployeeVM? UploadedBy { get; set; }
public DateTime? UpdatedAt { get; set; } public DateTime? UpdatedAt { get; set; }

View File

@ -12,6 +12,8 @@ namespace Marco.Pms.Model.ViewModels.DocumentManager
public int Version { get; set; } public int Version { get; set; }
public bool IsCurrentVersion { get; set; } public bool IsCurrentVersion { get; set; }
public Guid ParentAttachmentId { get; set; } public Guid ParentAttachmentId { get; set; }
public long FileSize { get; set; }
public string? ContentType { get; set; }
public DateTime UploadedAt { get; set; } public DateTime UploadedAt { get; set; }
public BasicEmployeeVM? UploadedBy { get; set; } public BasicEmployeeVM? UploadedBy { get; set; }
public DateTime? UpdatedAt { get; set; } public DateTime? UpdatedAt { get; set; }

View File

@ -267,6 +267,8 @@ namespace Marco.Pms.Services.Controllers
.Include(av => av.ChildAttachment) .Include(av => av.ChildAttachment)
.ThenInclude(da => da!.DocumentType) .ThenInclude(da => da!.DocumentType)
.ThenInclude(dt => dt!.DocumentCategory) .ThenInclude(dt => dt!.DocumentCategory)
.Include(av => av.ChildAttachment)
.ThenInclude(da => da!.Document)
.FirstOrDefaultAsync(av => av.ChildAttachmentId == id && av.TenantId == tenantId); .FirstOrDefaultAsync(av => av.ChildAttachmentId == id && av.TenantId == tenantId);
// If no mapping found, return 404 // If no mapping found, return 404
@ -299,6 +301,9 @@ namespace Marco.Pms.Services.Controllers
documentAttachmentVM.Version = versionMapping.Version; documentAttachmentVM.Version = versionMapping.Version;
documentAttachmentVM.ParentAttachmentId = versionMapping.ParentAttachmentId; documentAttachmentVM.ParentAttachmentId = versionMapping.ParentAttachmentId;
documentAttachmentVM.Tags = tags; documentAttachmentVM.Tags = tags;
documentAttachmentVM.FileSize = versionMapping.ChildAttachment.Document!.FileSize;
documentAttachmentVM.ContentType = versionMapping.ChildAttachment.Document.ContentType;
_logger.LogInfo("Document details fetched successfully for AttachmentId: {AttachmentId}", id); _logger.LogInfo("Document details fetched successfully for AttachmentId: {AttachmentId}", id);
// Return success response with document details // Return success response with document details
@ -421,6 +426,8 @@ namespace Marco.Pms.Services.Controllers
.ThenInclude(da => da!.UploadedBy) .ThenInclude(da => da!.UploadedBy)
.Include(av => av.ChildAttachment) .Include(av => av.ChildAttachment)
.ThenInclude(da => da!.UpdatedBy) .ThenInclude(da => da!.UpdatedBy)
.Include(av => av.ChildAttachment)
.ThenInclude(da => da!.Document)
.Where(av => av.ParentAttachmentId == parentAttachmentId && av.TenantId == tenantId); .Where(av => av.ParentAttachmentId == parentAttachmentId && av.TenantId == tenantId);
var totalCount = await versionMappingsQuery.CountAsync(); var totalCount = await versionMappingsQuery.CountAsync();
@ -449,6 +456,8 @@ namespace Marco.Pms.Services.Controllers
{ {
var documentVM = _mapper.Map<AttachmentVersionVM>(versionMapping.ChildAttachment); var documentVM = _mapper.Map<AttachmentVersionVM>(versionMapping.ChildAttachment);
documentVM.Version = versionMapping.Version; documentVM.Version = versionMapping.Version;
documentVM.FileSize = versionMapping.ChildAttachment!.Document!.FileSize;
documentVM.ContentType = versionMapping.ChildAttachment.Document!.ContentType;
return documentVM; return documentVM;
}).ToList(); }).ToList();