ASP.NET / ASP.NET Helpdesk System Using jQuery and Bootstrap / CasestudyWebsite / Controllers / ReportController.cs
ReportController.cs
Raw
/*
 * Description: The ReportController class is a controller for handling requests related to reports.
 *              It provides methods for generating Employee and Call reports using the EmployeeReport and CallReport classes.
 */
using Microsoft.AspNetCore.Mvc;
using CasestudyWebsite.Reports;
namespace CasestudyWebsite.Controllers
{
    public class ReportController : Controller
    {
        private readonly IWebHostEnvironment _env;
        public ReportController(IWebHostEnvironment env)
        {
            _env = env;
        }

        [Route("api/employeereport")]
        [HttpGet]
        public async Task<IActionResult> GetEmployeeReport()
        {
            EmployeeReport report = new();
            await report.GenerateReport(_env.WebRootPath);
            return Ok(new { msg = "Report Generated" });
        }

        [Route("api/callreport")]
        [HttpGet]
        public async Task<IActionResult> GetCallReport()
        {
            CallReport report = new();
            await report.GenerateReport(_env.WebRootPath);
            return Ok(new { msg = "Report Generated" });
        }
    }
}