From 4d69413e29d0704231185761ad6995b6e7edad65 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sat, 7 Jun 2025 19:27:57 +0530 Subject: [PATCH] changes response format and added new end point for fetching documents --- .../Controllers/MasterController.cs | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/Marco.Pms.Services/Controllers/MasterController.cs b/Marco.Pms.Services/Controllers/MasterController.cs index 5a76e4f..be56e3f 100644 --- a/Marco.Pms.Services/Controllers/MasterController.cs +++ b/Marco.Pms.Services/Controllers/MasterController.cs @@ -671,6 +671,26 @@ namespace Marco.Pms.Services.Controllers //-------------------Document------------------------------------- + [HttpGet("documents")] + public async Task GetDocumentMaster() + { + try + { + Guid tenantId = _userHelper.GetTenantId(); + + var documentMast = await _context.DocumentMasters + .Where(d => d.TenantId == tenantId) + .ToListAsync(); + + + return Ok(ApiResponse.SuccessResponse(documentMast, "Document List", 200)); + } + catch (Exception ex) + { + return StatusCode(500, ApiResponse.ErrorResponse("An error occurred", ex.Message, 500)); + } + } + [HttpPost("document")] public async Task CreateDocument([FromBody] DocumentMasterDto documentMaster) @@ -713,7 +733,7 @@ namespace Marco.Pms.Services.Controllers await _context.DocumentMasters.AddAsync(newDocument); await _context.SaveChangesAsync(); - return Ok(ApiResponse.SuccessResponse("Document created successfully", "Success", 200)); + return Ok(ApiResponse.SuccessResponse(newDocument,"Document created successfully", 200)); } catch (Exception ex) { @@ -764,7 +784,19 @@ namespace Marco.Pms.Services.Controllers _context.DocumentMasters.Update(existingDocument); await _context.SaveChangesAsync(); - return Ok(ApiResponse.SuccessResponse("Document updated successfully", "Success", 200)); + + var updatedDto = new DocumentMaster + { + Id = existingDocument.Id, + Name = existingDocument.Name, + Type = existingDocument.Type, + Description = existingDocument.Description, + ValidationException = existingDocument.ValidationException, + IsRequired = existingDocument.IsRequired + // Add other fields as needed + }; + + return Ok(ApiResponse.SuccessResponse(updatedDto,"Document updated successfully", 200)); } catch (Exception ex) {