EchoTex_Payroll/HRM.UI/Controllers/CoreHrDashboard/CoreHrDashboardController.cs

202 lines
5.6 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Data;
using HRM.BO;
using HRM.DA;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace HRM.UI.Controllers.CoreHrDashboard
{
[ApiController]
[Route("api/CoreHrDashboard")]
[Authorize]
public class CoreHrDashboardController : ControllerBase
{
private readonly IEmployeeService _employeeService;
public CoreHrDashboardController(IEmployeeService employeeService)
{
_employeeService = employeeService;
}
[HttpGet("getGeneralData")]
public ActionResult GetGeneralData()
{
DataSet ds = new DataSet();
try
{
ds = _employeeService.GetEmployeeGeneralData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet("getContactData")]
public ActionResult GetContactData()
{
DataSet ds = new DataSet();
try
{
ds = _employeeService.GetEmployeeContactData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet("getSpouseData")]
public ActionResult GetSpouseData()
{
DataSet ds = new DataSet();
try
{
ds = _employeeService.GetEmployeeSpouseData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet("getChildrenData")]
public ActionResult GetChildrenData()
{
DataSet ds = new DataSet();
try
{
ds = _employeeService.GetEmployeeChildrenData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet("getAcademicData")]
public ActionResult GetAcademicData()
{
DataSet ds = new DataSet();
try
{
ds = _employeeService.GetEmployeeAcademicData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet("getTrainingData")]
public ActionResult GetTrainingData()
{
DataSet ds = new DataSet();
try
{
ds = _employeeService.GetEmployeeTrainingData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet("getExperienceData")]
public ActionResult GetExperienceData()
{
DataSet ds = new DataSet();
try
{
ds = _employeeService.GetEmployeeExperienceData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet("getNomineeData")]
public ActionResult getNomineeData()
{
DataSet ds = new DataSet();
try
{
ds = new EmployeeService().GetEmployeeNomineeData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet("getEmployeeGenderRatio")]
public ActionResult GetEmployeeGenderRatio()
{
DataSet ds = new DataSet();
try
{
ds = _employeeService.GetEmployeeGenderRatio();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet("getEmployeeSummaryData")]
public ActionResult GetEmployeeSummaryData()
{
DataSet ds = new DataSet();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int id = currentUser.EmployeeID.GetValueOrDefault();
Employee emp = _employeeService.Get(id);
try
{
if (emp != null && emp.LineManagerID != null)
{
ds = _employeeService.GetEmployeeSummaryDataByDepartment(emp);
}
else
ds = _employeeService.GetEmployeeSummaryData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet("getEmployeeAttritionData")]
public ActionResult GetEmployeeAttritionData()
{
DataSet ds = new DataSet();
try
{
ds = _employeeService.GetEmployeeAttritionData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
}
}