PSTW_CentralizeSystem/Areas/MMS/Controllers/MarineController.cs
2025-03-28 10:29:59 +08:00

40 lines
1.2 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PSTW_CentralSystem.Areas.MMS;
using QuestPDF.Fluent;
namespace PSTW_CentralSystem.Areas.MMS.Controllers
{
[Area("MMS")]
//[Authorize(Policy = "RoleModulePolicy")]
public class MarineController : Controller
{
public IActionResult Index()
{
return View(); // This will look for Index.cshtml in Areas/MMS/Views/Marine
}
public IActionResult TarBallForm()
{
return View();
}
// Generates and returns a Tar Ball Sampling Report PDF
public IActionResult GenerateReport()
{
try
{
var document = new TarBallPDF();
var pdf = document.GeneratePdf();
return File(pdf, "application/pdf", "TarBallReport.pdf");
}
catch (Exception ex)
{
// Log the error (use a logger if configured)
Console.WriteLine(ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, "An error occurred while generating the PDF.");
}
}
}
}