565 lines
20 KiB
C#
565 lines
20 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Net.Http;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using HRM.BO;
|
|||
|
|
using HRM.DA;
|
|||
|
|
using HRM.UI.DTOs.Training;
|
|||
|
|
using Microsoft.AspNetCore.Authorization;
|
|||
|
|
using Microsoft.AspNetCore.Http;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
|
|||
|
|
namespace HRM.UI.Controllers
|
|||
|
|
{
|
|||
|
|
[ApiController]
|
|||
|
|
[Route("api/EmpLifeCycle")]
|
|||
|
|
[Authorize]
|
|||
|
|
public class EmpLifeCycleController : ControllerBase
|
|||
|
|
{
|
|||
|
|
private readonly IUserService _userService;
|
|||
|
|
private readonly IEmployeeStatusService _employeeStatusService;
|
|||
|
|
IEmpLifeCycleService _lifeCycleService;
|
|||
|
|
IEmployeeGradeSalaryService _empGradeSalaries;
|
|||
|
|
private readonly IPayrollTypeService _payrollTypeService;
|
|||
|
|
private readonly IEmpHistoricalDataService _empHistoricalDataService;
|
|||
|
|
public EmpLifeCycleController(IEmployeeStatusService empStatus,
|
|||
|
|
IEmpLifeCycleService lifeCycleService,
|
|||
|
|
IEmployeeStatusService employeeStatusService, IPayrollTypeService pTypeService,
|
|||
|
|
IUserService userService, IEmployeeGradeSalaryService empGradeSalaries,
|
|||
|
|
IEmpHistoricalDataService empHistoricalDataService)
|
|||
|
|
{
|
|||
|
|
_employeeStatusService = employeeStatusService;
|
|||
|
|
_lifeCycleService = lifeCycleService;
|
|||
|
|
_userService = userService;
|
|||
|
|
_empGradeSalaries = empGradeSalaries;
|
|||
|
|
this._payrollTypeService = pTypeService;
|
|||
|
|
this._empHistoricalDataService = empHistoricalDataService;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("SaveLifeCycle")]
|
|||
|
|
public ActionResult SaveLifeCycle(EmpLifeCycle lifecycle)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
int payrollId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|||
|
|
lifecycle.CreatedBy = currentUser.UserID;
|
|||
|
|
//lifecycle.CreatedDate = DateTime.Today;
|
|||
|
|
lifecycle.SalaryMonth = (DateTime)currentUser.NextPayProcessDate;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (lifecycle.IsNew == true)
|
|||
|
|
{
|
|||
|
|
if (lifecycle.EffectDate.Date <= (DateTime)currentUser.NextPayProcessDate)
|
|||
|
|
{
|
|||
|
|
lifecycle.IsProcessed = null;
|
|||
|
|
lifecycle.ProcessDate = null;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lifecycle.IsProcessed = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return Ok(this._lifeCycleService.Save(lifecycle, (DateTime)currentUser.NextPayProcessDate, payrollId));
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("deleteGradeSalary")]
|
|||
|
|
public ActionResult deleteGradeSalary(EmployeeGradeSalary item)
|
|||
|
|
{
|
|||
|
|
if(item.ArrearType != EnumArrearType.ToCalculate)
|
|||
|
|
{
|
|||
|
|
throw new Exception("Only Arrear item are allowed to delete");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
this._empGradeSalaries.Delete(item.ID);
|
|||
|
|
return Ok(true);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
[HttpPost("getEmpLifeCyclesByDate")]
|
|||
|
|
public ActionResult GetEmpLifeCycles(dynamic data)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
int payrollId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|||
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|||
|
|
DateTime fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
|
|||
|
|
DateTime toDate = (DateTime)items["toDate"].ToObject<DateTime>();
|
|||
|
|
List<EmpLifeCycle> empLifeCycles = new List<EmpLifeCycle>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
empLifeCycles = _lifeCycleService.GetApprovalPending(payrollId);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(empLifeCycles);
|
|||
|
|
}
|
|||
|
|
[HttpPost("getEmpLifeCyclesByDateNew")]
|
|||
|
|
public ActionResult GetEmpLifeCyclesNew(dynamic data)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
int payrollId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|||
|
|
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
|
|||
|
|
DateTime fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
|
|||
|
|
DateTime toDate = (DateTime)items["toDate"].ToObject<DateTime>();
|
|||
|
|
List<EmpLifeCycle> empLifeCycles = new List<EmpLifeCycle>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//empLifeCycles = _lifeCycleService.GetByDateNew(fromDate, toDate, payrollId);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(empLifeCycles);
|
|||
|
|
}
|
|||
|
|
[HttpGet("getEmpLifeByStatus/{status}")]
|
|||
|
|
public ActionResult GetEmpLifeByStatus(EnumStatus status)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
int payrollId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|||
|
|
List<EmpLifeCycle> empLifeCycles = new List<EmpLifeCycle>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
empLifeCycles = _lifeCycleService.Get(status, payrollId);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(empLifeCycles);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet("getEmpLifeCycles/{EmpID}")]
|
|||
|
|
public ActionResult GetEmpLifeCycles(int EmpID)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
return Ok(this._lifeCycleService.GetEmpID(EmpID));
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet("get/{sts}")]
|
|||
|
|
public List<EmployeeStatus> Get(EnumStatus sts)
|
|||
|
|
{
|
|||
|
|
EmployeeStatusService service = new EmployeeStatusService();
|
|||
|
|
return service.Get(sts);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Life-Cycle Event list: the screen's Payroll Type dropdown drives this.
|
|||
|
|
[HttpGet("getByPayrollType/{sts}")]
|
|||
|
|
public List<EmployeeStatus> getByPayrollType(EnumStatus sts)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
int payrollTypeID = currentUser.PayrollTypeID.GetValueOrDefault();
|
|||
|
|
return this._employeeStatusService.Get(sts, payrollTypeID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet("getEmpStatus")]
|
|||
|
|
public List<EmployeeStatus> GetEmpStatus()
|
|||
|
|
{
|
|||
|
|
EmployeeStatusService service = new EmployeeStatusService();
|
|||
|
|
return service.Get();
|
|||
|
|
}
|
|||
|
|
//[HttpGet("get")]
|
|||
|
|
//public List<Configaration> GetChilds(string NodeName, EnumConfigurationType type);
|
|||
|
|
//{
|
|||
|
|
// //EmployeeStatusService service = new EmployeeStatusService();
|
|||
|
|
// //return service.Get();
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet("GetByUserID")]
|
|||
|
|
public ActionResult GetByUserID()
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
List<EmployeeStatus> oEmpStatusComponent = new List<EmployeeStatus>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
oEmpStatusComponent = this._employeeStatusService.GetByUserID(currentUser.UserID);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(oEmpStatusComponent);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet("GetEmployeeGradeSalaries/{empid}")]
|
|||
|
|
public ActionResult GetEmployeeGradeSalaries(int empid)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
List<EmployeeGradeSalary> salaries = new List<EmployeeGradeSalary>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
salaries = this._empGradeSalaries.Get(empid);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(salaries);
|
|||
|
|
}
|
|||
|
|
[HttpGet("GetSalaryHistory/{empid}")]
|
|||
|
|
public ActionResult GetSalaryHistory(int empid)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
DataTable items =null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
items = this._empGradeSalaries.GetSalaryHistory(empid);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(items);
|
|||
|
|
}
|
|||
|
|
[HttpGet("getEmpStatusComponent/{id}")]
|
|||
|
|
public ActionResult GetEmpStatusComponent(int id)
|
|||
|
|
{
|
|||
|
|
List<EmployeeStatus.EmpStatusComponent> oEmpStatusComponent = new List<EmployeeStatus.EmpStatusComponent>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
oEmpStatusComponent = this._employeeStatusService.GetChild(id);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(oEmpStatusComponent);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet("getEmpStatusComponentUser/{id}")]
|
|||
|
|
public ActionResult GetEmpStatusComponentUser(int id)
|
|||
|
|
{
|
|||
|
|
List<EmployeeStatus.EmployeeStatusComponentUser> oEmployeeStatusComponentUser =
|
|||
|
|
new List<EmployeeStatus.EmployeeStatusComponentUser>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
oEmployeeStatusComponentUser = this._employeeStatusService.GetEmpStatusComponentUser(id);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(oEmployeeStatusComponentUser);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost("submit-employee-status")]
|
|||
|
|
[IgnoreAntiforgeryToken]
|
|||
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|||
|
|
public HttpResponseMessage save(EmployeeStatus oEmployeeStatus)
|
|||
|
|
{
|
|||
|
|
// CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
// var tempDate = oLeaveEntry.EntryDate;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//ouser.CreatedBy = currentUser.UserID;
|
|||
|
|
//ouser.CreatedDate = DateTime.Now;
|
|||
|
|
//ouser.ParentID = currentUser.UserID;
|
|||
|
|
|
|||
|
|
_employeeStatusService.Save(oEmployeeStatus);
|
|||
|
|
return new HttpResponseMessage(System.Net.HttpStatusCode.OK);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
return new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
[HttpGet("GetAllPayrollTypes")]
|
|||
|
|
public ActionResult GetAllPayrollTypes()
|
|||
|
|
{
|
|||
|
|
List<PayrollType> items = new List<PayrollType>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
items = this._payrollTypeService.Get();
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
int payrollId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|||
|
|
items = items.Where(x => x.ID != payrollId).ToList();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(items);
|
|||
|
|
}
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("UpdateApprovalStatus")]
|
|||
|
|
public ActionResult UpdateApprovalStatus(List<EmpLifeCycle> lifecycle)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
int payrollId = currentUser.PayrollTypeID.GetValueOrDefault();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
this._lifeCycleService.UpdateApprovalStatus(lifecycle, payrollId);
|
|||
|
|
return Ok(true);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet("getUsers")]
|
|||
|
|
public ActionResult GetUsers()
|
|||
|
|
{
|
|||
|
|
List<User> _users = new List<User>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_users = _userService.GetAll();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(_users);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//[HttpGet("getAllUser")]
|
|||
|
|
//public ActionResult GetAllUser()
|
|||
|
|
//{
|
|||
|
|
// List<User> items = new List<User>();
|
|||
|
|
// try
|
|||
|
|
// {
|
|||
|
|
// items = this._userService.Get();
|
|||
|
|
// }
|
|||
|
|
// catch (Exception ex)
|
|||
|
|
// {
|
|||
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
// return Ok(items);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
// Employee Status
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("saveEmployeeStatus")]
|
|||
|
|
public ActionResult SaveCostCenterList(EmployeeStatus item)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
item.PayrollTypeID = currentUser.PayrollTypeID.GetValueOrDefault();
|
|||
|
|
|
|||
|
|
_employeeStatusService.SaveStatus(item);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// Life-Cycle Event list: the Active / In-Active button in the Action column.
|
|||
|
|
// The caller sends the row with Status already set to the value it wants.
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("updateEmployeeStatusStatus")]
|
|||
|
|
public ActionResult UpdateEmployeeStatusStatus(EmployeeStatus item)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_employeeStatusService.UpdateStatus(item);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("DeleteEmployeeStatus")]
|
|||
|
|
public ActionResult DeleteEmployeeStatus(EmployeeStatus item)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_employeeStatusService.Delete(item.ID);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("DeleteEmpLifecycele")]
|
|||
|
|
public ActionResult DeleteEmpLifecycele(EmpLifeCycle item)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_lifeCycleService.Delete(item, (DateTime) currentUser.NextPayProcessDate);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet("getEmpCareerHistoryReportData/{employeeID}")]
|
|||
|
|
public ActionResult getEmpCareerHistoryReportData(int employeeID)
|
|||
|
|
{
|
|||
|
|
DataTable oDataTable = new DataTable();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
oDataTable = new EmpLifeCycleService().getEmpCareerHistoryReportData(employeeID);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
return Ok(oDataTable);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region Historical Career Data Upload
|
|||
|
|
|
|||
|
|
// Serves the EmpHistoricalData holding table only; these endpoints never write
|
|||
|
|
// employee master data, EmpLifeCycle or payroll data.
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Rows already uploaded for the current payroll type ("Uploaded Data").
|
|||
|
|
/// </summary>
|
|||
|
|
/// <summary>
|
|||
|
|
/// The department and location tiers the sheet must carry, read from the Logic
|
|||
|
|
/// configuration, so the screen builds its columns from configuration rather
|
|||
|
|
/// than hardcoding them.
|
|||
|
|
/// </summary>
|
|||
|
|
[HttpGet("getHistoricalDataColumnSetup")]
|
|||
|
|
public ActionResult GetHistoricalDataColumnSetup()
|
|||
|
|
{
|
|||
|
|
EmpHistoricalDataColumnSetup setup = new EmpHistoricalDataColumnSetup();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
setup = this._empHistoricalDataService.GetColumnSetup();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(setup);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet("getHistoricalData")]
|
|||
|
|
public ActionResult GetHistoricalData()
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
List<EmpHistoricalData> items = new List<EmpHistoricalData>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
items = this._empHistoricalDataService.Get(currentUser.PayrollTypeID.GetValueOrDefault());
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(items);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Appends the rows staged in the grid ("Upload").
|
|||
|
|
/// </summary>
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("saveHistoricalData")]
|
|||
|
|
public ActionResult SaveHistoricalData(List<EmpHistoricalData> items)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
List<UploadErrorOrSuccess> unmatched = new List<UploadErrorOrSuccess>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
unmatched = this._empHistoricalDataService.Save(items,
|
|||
|
|
currentUser.PayrollTypeID.GetValueOrDefault(), currentUser.UserID);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok(unmatched);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Deletes the one uploaded row identified by EmpHistoricalDataID.
|
|||
|
|
/// </summary>
|
|||
|
|
[HttpPost]
|
|||
|
|
[Route("deleteHistoricalData")]
|
|||
|
|
public ActionResult DeleteHistoricalData(EmpHistoricalData item)
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (item == null || item.ID <= 0)
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError,
|
|||
|
|
"No historical career record was identified for deletion.");
|
|||
|
|
|
|||
|
|
this._empHistoricalDataService.Delete(item.ID,
|
|||
|
|
currentUser.PayrollTypeID.GetValueOrDefault());
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Ok();
|
|||
|
|
}
|
|||
|
|
// Users allowed on one payroll type (UserAccessType) -- the Life-Cycle Event
|
|||
|
|
// entry screen picks its approvers from this list.
|
|||
|
|
[HttpGet]
|
|||
|
|
[Route("GetUsersByPayrollType/{userType}")]
|
|||
|
|
public ActionResult GetUsersByPayrollType(EnumUserType userType)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
|||
|
|
int payrollTypeID = currentUser.PayrollTypeID.GetValueOrDefault();
|
|||
|
|
List <User> olist = _userService.GetByPayrollType(userType, payrollTypeID);
|
|||
|
|
return Ok(olist);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|