using Microsoft.AspNetCore.Mvc; namespace CPRNIMS.WebApps.ViewComponents.POMgmt { public class CustomFormPOElemVC : ViewComponent { public IViewComponentResult Invoke(int poTypeId) { try { string viewName = poTypeId switch { 1 => "~/Views/Components/POMgmt/CustomPO/SIElem.cshtml", 2 => "~/Views/Components/POMgmt/CustomPO/DRElem.cshtml", _ => "~/Views/Components/POMgmt/CustomPO/ImportElem.cshtml" }; return View(viewName); } catch (Exception ex) { // Log the error (use a logger in production) Console.WriteLine($"Error in CustomFormPOElemVC: {ex.Message}"); return Content("An error occurred while loading the view."); } } } }