changes response format and added new end point for fetching documents
This commit is contained in:
parent
6f57e9d2d6
commit
4d69413e29
@ -671,6 +671,26 @@ namespace Marco.Pms.Services.Controllers
|
||||
|
||||
|
||||
//-------------------Document-------------------------------------
|
||||
[HttpGet("documents")]
|
||||
public async Task<IActionResult> GetDocumentMaster()
|
||||
{
|
||||
try
|
||||
{
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
|
||||
var documentMast = await _context.DocumentMasters
|
||||
.Where(d => d.TenantId == tenantId)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
return Ok(ApiResponse<object>.SuccessResponse(documentMast, "Document List", 200));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, ApiResponse<object>.ErrorResponse("An error occurred", ex.Message, 500));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("document")]
|
||||
public async Task<IActionResult> CreateDocument([FromBody] DocumentMasterDto documentMaster)
|
||||
@ -713,7 +733,7 @@ namespace Marco.Pms.Services.Controllers
|
||||
await _context.DocumentMasters.AddAsync(newDocument);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Ok(ApiResponse<string>.SuccessResponse("Document created successfully", "Success", 200));
|
||||
return Ok(ApiResponse<object>.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<string>.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<object>.SuccessResponse(updatedDto,"Document updated successfully", 200));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user