handle error

This commit is contained in:
pramod mahajan 2025-08-18 23:31:18 +05:30
parent 3ba954ac82
commit e8c8c92120

View File

@ -134,8 +134,6 @@ namespace Marco.Pms.Services.Controllers
} }
} }
[HttpPut("sidebar/{sectionId}/items/{itemId}")] [HttpPut("sidebar/{sectionId}/items/{itemId}")]
public async Task<IActionResult> UpdateMenuItem(Guid sectionId, Guid itemId, [FromBody] MenuItemDto updatedMenuItem) public async Task<IActionResult> UpdateMenuItem(Guid sectionId, Guid itemId, [FromBody] MenuItemDto updatedMenuItem)
{ {
@ -231,6 +229,9 @@ namespace Marco.Pms.Services.Controllers
var loggedUser = await _userHelper.GetCurrentEmployeeAsync(); var loggedUser = await _userHelper.GetCurrentEmployeeAsync();
var employeeId = loggedUser.Id; var employeeId = loggedUser.Id;
try
{
var menus = await _sideBarMenuHelper.GetAllMenuSectionsAsync(); var menus = await _sideBarMenuHelper.GetAllMenuSectionsAsync();
foreach (var menu in menus) foreach (var menu in menus)
@ -297,7 +298,16 @@ namespace Marco.Pms.Services.Controllers
menu.Items = allowedItems; menu.Items = allowedItems;
} }
return Ok(menus); _logger.LogInfo("Fetched Sidebar Menu");
return Ok(ApiResponse<object>.SuccessResponse(menus, "SideBar Menu Fetched successfully"));
}
catch (Exception ex) {
_logger.LogError(ex, "Error Occurred while Updating Fetching Menu");
return StatusCode(500, ApiResponse<object>.ErrorResponse("Server Error", ex, 500));
}
} }