Added the get list of Document type API #117
@ -9,6 +9,7 @@
|
||||
public int MaxFilesAllowed { get; set; }
|
||||
public double MaxSizeAllowedInKB { get; set; }
|
||||
public bool IsValidationRequired { get; set; }
|
||||
public bool IsMandatory { get; set; }
|
||||
public bool IsSystem { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public DocumentCategoryVM? DocumentCategory { get; set; }
|
||||
|
@ -960,6 +960,17 @@ namespace Marco.Pms.Services.Controllers
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region =================================================================== Document Type APIs ===================================================================
|
||||
|
||||
[HttpGet("document-type/list")]
|
||||
public async Task<IActionResult> GetDocumentTypeMasterList([FromQuery] Guid? documentCategoryId)
|
||||
{
|
||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
var response = await _masterService.GetDocumentTypeMasterListAsync(documentCategoryId, loggedInEmployee, tenantId);
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +315,8 @@ namespace Marco.Pms.Services.MappingProfiles
|
||||
|
||||
CreateMap<DocumentCategoryMaster, DocumentCategoryVM>();
|
||||
CreateMap<DocumentAttachmentDto, DocumentAttachment>();
|
||||
CreateMap<DocumentAttachmentDto, DocumentAttachment>();
|
||||
|
||||
CreateMap<DocumentTypeMaster, DocumentTypeVM>();
|
||||
CreateMap<DocumentAttachmentDto, DocumentAttachment>();
|
||||
|
||||
#endregion
|
||||
|
@ -544,6 +544,54 @@ namespace Marco.Pms.Services.Service
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region =================================================================== Document Type APIs ===================================================================
|
||||
|
||||
|
||||
public async Task<ApiResponse<object>> GetDocumentTypeMasterListAsync(Guid? documentCategoryId, Employee loggedInEmployee, Guid tenantId)
|
||||
{
|
||||
try
|
||||
{
|
||||
// ✅ Tenant validation
|
||||
if (tenantId != loggedInEmployee.TenantId)
|
||||
{
|
||||
_logger.LogWarning("Access denied. Employee {EmployeeId} (TenantId: {EmployeeTenantId}) attempted to fetch document types for TenantId: {RequestedTenantId}",
|
||||
loggedInEmployee.Id, loggedInEmployee.TenantId, tenantId);
|
||||
|
||||
return ApiResponse<object>.ErrorResponse("Access Denied", "You do not have access to this information", 403);
|
||||
}
|
||||
|
||||
// ✅ Build query
|
||||
IQueryable<DocumentTypeMaster> documentTypeQuery = _context.DocumentTypeMasters
|
||||
.AsNoTracking() // optimization: read-only
|
||||
.Where(dc => dc.TenantId == tenantId);
|
||||
|
||||
// ✅ Apply optional filter
|
||||
if (documentCategoryId.HasValue)
|
||||
{
|
||||
documentTypeQuery = documentTypeQuery.Where(dc => dc.DocumentCategoryId == documentCategoryId.Value);
|
||||
}
|
||||
|
||||
// ✅ Fetch and map
|
||||
var documentType = await documentTypeQuery.ToListAsync();
|
||||
var response = _mapper.Map<List<DocumentTypeVM>>(documentType);
|
||||
|
||||
_logger.LogInfo("{Count} document type fetched successfully for TenantId: {TenantId} by Employee {EmployeeId}",
|
||||
response.Count, tenantId, loggedInEmployee.Id);
|
||||
|
||||
return ApiResponse<object>.SuccessResponse(response, $"{response.Count} document type have been fetched successfully.", 200);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error occurred while fetching document type for TenantId: {TenantId} by Employee {EmployeeId}",
|
||||
tenantId, loggedInEmployee.Id);
|
||||
|
||||
return ApiResponse<object>.ErrorResponse("Internal Server Error", "Server Error occured", 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region =================================================================== Helper Function ===================================================================
|
||||
|
@ -27,12 +27,19 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces
|
||||
|
||||
#endregion
|
||||
|
||||
#region =================================================================== Payment mode APIs ===================================================================
|
||||
#region =================================================================== Document Category APIs ===================================================================
|
||||
Task<ApiResponse<object>> GetDocumentCategoryMasterListAsync(Guid? entityTypeId, Employee loggedInEmployee, Guid tenantId);
|
||||
//Task<ApiResponse<object>> CreatePaymentModeAsync(PaymentModeMatserDto model, Employee loggedInEmployee, Guid tenantId);
|
||||
//Task<ApiResponse<object>> UpdatePaymentModeAsync(Guid id, PaymentModeMatserDto model, Employee loggedInEmployee, Guid tenantId);
|
||||
//Task<ApiResponse<object>> DeletePaymentModeAsync(Guid id, bool isActive, Employee loggedInEmployee, Guid tenantId);
|
||||
|
||||
#endregion
|
||||
#region =================================================================== Document Type APIs ===================================================================
|
||||
Task<ApiResponse<object>> GetDocumentTypeMasterListAsync(Guid? documentCategoryId, Employee loggedInEmployee, Guid tenantId);
|
||||
//Task<ApiResponse<object>> CreatePaymentModeAsync(PaymentModeMatserDto model, Employee loggedInEmployee, Guid tenantId);
|
||||
//Task<ApiResponse<object>> UpdatePaymentModeAsync(Guid id, PaymentModeMatserDto model, Employee loggedInEmployee, Guid tenantId);
|
||||
//Task<ApiResponse<object>> DeletePaymentModeAsync(Guid id, bool isActive, Employee loggedInEmployee, Guid tenantId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user