NonInventPurchasingSystem/CPRNIMS.WebApps/ViewComponents/POMgmt/CustomFormPOElemVC.cs
2026-01-20 07:44:30 +08:00

30 lines
916 B
C#

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.");
}
}
}
}