Added an API endpoint to retrieve the Work Category by ID
This commit is contained in:
parent
648d8e691a
commit
20ea1389dd
@ -563,5 +563,23 @@ namespace Marco.Pms.Services.Controllers
|
||||
_logger.LogInfo("{count} Work Category records fetched successfully from tenant {tenantId}", workCategoryMasterVMs.Count, tenantId);
|
||||
return Ok(ApiResponse<object>.SuccessResponse(workCategoryMasterVMs, System.String.Format("{0} Work Category records fetched successfully", workCategoryMasterVMs.Count), 200));
|
||||
}
|
||||
|
||||
[HttpGet("work-category/{id})")]
|
||||
public async Task<IActionResult> GetWorkCategoryMaster(Guid id)
|
||||
{
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
WorkCategoryMaster? workCategory = await _context.WorkCategoryMasters.FirstOrDefaultAsync(s => s.TenantId == tenantId && s.Id == id);
|
||||
if (workCategory != null)
|
||||
{
|
||||
WorkCategoryMasterVM workCategoryMasterVM = workCategory.ToWorkCategoryMasterVMFromWorkCategoryMaster();
|
||||
_logger.LogInfo("{WorkCategoryId} Work Category fetched successfully from tenant {tenantId}", workCategoryMasterVM.Id ?? Guid.Empty, tenantId);
|
||||
return Ok(ApiResponse<object>.SuccessResponse(workCategoryMasterVM, "Work Category fetched successfully", 200));
|
||||
}
|
||||
|
||||
_logger.LogInfo("{WorkCategoryId} Work Category not found in database", id);
|
||||
return NotFound(ApiResponse<object>.ErrorResponse("Work Category not found", "Work Category not found", 404));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user