EchoTex_Payroll/HRM.UI/Controllers/Employee/EmployeeController.cs
2024-10-14 10:01:49 +06:00

2790 lines
103 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using AutoMapper;
using HRM.BO;
using HRM.BO.Report;
//using HRM.BO.Report;
using HRM.DA;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System.IO;
using HRM.BO.Configuration;
using Microsoft.Extensions.Options;
using static Azure.Core.HttpHeader;
using iTextSharp.text;
using static iTextSharp.text.pdf.AcroFields;
namespace HRM.UI.Controllers
{
[ApiController]
[Route("api/Employee")]
[Authorize]
public class EmployeeController : ControllerBase
{
private readonly IEmployeeService _EmployeeService;
private readonly IMapper _mapper;
ISearchEmployeeService _serachManager;
IHREmployeeService _hrEmployeeService;
IEmployeeBankAccountService _employeeBankAccountService;
private IEmployeeCostCenterService _employeeCostCenterService;
private readonly IDepartmentService _departmentService;
private readonly IDesignationService _designationService;
private readonly ILocationService _locationService;
private readonly ICostcenterService _costCenterService;
private readonly IOptions<EmployeeApiInfo> _employeeApiInfo;
private readonly IPayrollTypeService _payrollTypeService;
public EmployeeController(ISearchEmployeeService searchManager,
IHREmployeeService hREmployee, IEmployeeService empService,
IEmployeeBankAccountService employeeBankAccountService,
IEmployeeCostCenterService employeeCostCenterService,
IDepartmentService departmentService,
IDesignationService designationService,
ILocationService locationService,
ICostcenterService costCenterService,
IOptions<EmployeeApiInfo> employeeApiInfo,
IPayrollTypeService payrollTypeService)
{
_serachManager = searchManager;
_hrEmployeeService = hREmployee;
_EmployeeService = empService;
_employeeBankAccountService = employeeBankAccountService;
_employeeCostCenterService = employeeCostCenterService;
_departmentService = departmentService;
_designationService = designationService;
_locationService = locationService;
_costCenterService = costCenterService;
_employeeApiInfo = employeeApiInfo;
_payrollTypeService = payrollTypeService;
}
//[HttpGet("getemployees")]
//public List<Employee> GetEmployees()
//{
// EmployeeService service = new EmployeeService();
// return service.Get();
//}
[HttpPost]
[Route("getSearchEmployeeForCordinator")]
public ActionResult getSearchEmployeeForCordinator(SearchManager omanager)
{
List<SearchEmployee> olist = new List<SearchEmployee>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
olist = _serachManager.FindCordinator((int)currentUser.EmployeeID, currentUser.PayrollTypeID);
}
catch(Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(olist);
}
[HttpPost]
[Route("getSearchEmployee")]
public ActionResult getSearchEmployee(SearchManager omanager)
{
List<SearchEmployee> olist = new List<SearchEmployee>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (omanager.TaxParamID == 0 && currentUser.TaxParamID !=null) omanager.TaxParamID =(int) currentUser.TaxParamID;
if (currentUser.NextPayProcessDate != null) omanager.LastPayProcessMonth = GlobalFunctions.LastDateOfMonth( ((DateTime)currentUser.NextPayProcessDate).AddMonths(-1));
SearchManager.SearchParameter oparam =
omanager.Parameter.SearchParameters.FirstOrDefault(x =>
x.Paramter == EnumSearchParameter.PayrollTypeID);
if (oparam == null)
{
SearchManager.SearchParameter op = new SearchManager.SearchParameter();
op.DataType = EnumSearchObjDataType.Number;
op.ParameterValue = currentUser.PayrollTypeID;
op.Paramter = EnumSearchParameter.PayrollTypeID;
op.SqlOperator = EnumSQLOperator.EqualTo;
omanager.Parameter.SearchParameters.Add(op);
omanager.payrolltypeID = (int)currentUser.PayrollTypeID;
}
else
{
omanager.payrolltypeID = Convert.ToInt32( oparam.ParameterValue);
}
SearchManager.SearchParameter oparamLM =
omanager.Parameter.SearchParameters.FirstOrDefault(x =>
x.Paramter == EnumSearchParameter.LM);
if (oparamLM != null)
{
oparamLM.DataType = EnumSearchObjDataType.Number;
oparamLM.ParameterValue = currentUser.EmployeeID;
oparamLM.Paramter = EnumSearchParameter.LM;
oparamLM.SqlOperator = EnumSQLOperator.EqualTo;
}
try
{
omanager.checkDataPermission = currentUser.hasDataPermission;
omanager.userid = currentUser.UserID;
olist = _serachManager.Find(omanager);
//omanager.checkDataPermission = false;
#region data permission
//List<DataPermission> datapermissions = new DataPermissionService().Get(currentUser.UserID,
// (int)currentUser.PayrollTypeID);
//if (datapermissions != null && datapermissions.Count != 0)
//{
// List<SearchEmployee> items = new List<SearchEmployee>();
// foreach (var dataItem in olist)
// {
// foreach (DataPermission item in datapermissions)
// {
// switch (item.PermissionType)
// {
// case EnumDataPermissionType.Cagtegory:
// if (dataItem.CategoryID == item.ReferenceID)
// items.Add(dataItem);
// break;
// case EnumDataPermissionType.Department:
// if (dataItem.designationID == item.ReferenceID)
// items.Add(dataItem);
// break;
// case EnumDataPermissionType.Grade:
// if (dataItem.GradeID == item.ReferenceID)
// items.Add(dataItem);
// break;
// case EnumDataPermissionType.Location:
// if (dataItem.LocationID == item.ReferenceID)
// items.Add(dataItem);
// break;
// }
// }
// }
// olist = items;
//}
#endregion
//if (omanager.withName)
//{
// int? payrolltypeid = null;
// if(currentUser.PayrollTypeID != null )
// payrolltypeid = (int)currentUser.PayrollTypeID;
// else if (oparam != null)
// payrolltypeid =Convert.ToInt32( oparam.ParameterValue);
// if (payrolltypeid != null)
// {
// List<Grade> grades = new GradeService().Get(EnumStatus.Regardless, (int)payrolltypeid);
// List<Designation> designations =
// new DesignationService().Get(EnumStatus.Regardless, (int)payrolltypeid);
// List<Department> departments =
// new DepartmentService().Get(EnumStatus.Regardless, (int)payrolltypeid);
// olist.ForEach(x =>
// {
// var grd = grades.FirstOrDefault(d => d.ID == x.GradeID);
// if (grd != null) x.gradeName = grd.Name;
// var designation = designations.FirstOrDefault(d => d.ID == x.designationID);
// if (designation != null) x.designationName = designation.Name;
// var department = departments.FirstOrDefault(d => d.ID == x.DepartmentID);
// if (department != null) x.departmentName = department.Name;
// });
// }
//}
if (omanager.searchForSalary)
{
if (olist != null)
{
List<SalaryMonthly> salaries = new SalaryMonthlyService().GetWithoutDetail((DateTime)currentUser.NextPayProcessDate, (int)currentUser.PayrollTypeID);
foreach(SalaryMonthly sl in salaries)
{
olist.RemoveAll(x => x.EmployeeID == sl.EmployeeID);
}
}
}
if (omanager.searchUndoSalary)
{
if (olist != null)
{
List<SalaryMonthly> salaries = new SalaryMonthlyService().GetWithoutDetail((DateTime)currentUser.NextPayProcessDate, (int)currentUser.PayrollTypeID);
olist = salaries.Join(olist,
sm => sm.EmployeeID,
se => se.EmployeeID,
(sm, se) => se).ToList();
}
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(olist);
}
[HttpPost]
[Route("saveEmployee")]
public ActionResult SaveEmployee(Employee item)
{
int ans;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (item.IsNew == true)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
item.PayrollTypeID = (int) currentUser.PayrollTypeID;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
try
{
ans = _EmployeeService.Save(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ans);
}
[HttpPost]
[Route("saveHnmEmployee")]
public ActionResult saveHnmEmployee(Employee item)
{
int ans;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
DateTime ModifiedDate = new DateTime();
ModifiedDate = DateTime.Today;
int ModifiedBy = currentUser.UserID;
EmpContact empContact = null;
if (item.IsNew == true)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
item.PayrollTypeID = (int)currentUser.PayrollTypeID;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
if (!String.IsNullOrEmpty(item.Address))
{
empContact = new EmpContact();
empContact.PermanentAddress= item.Address;
}
List<object> employeeData = new List<object>();
employeeData.Add(item);
employeeData.Add(empContact);
try
{
new EmployeeService().SaveHnmEmployee(employeeData);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpPost]
[Route("saveEmployeeList")]
public ActionResult SaveEmployeeList(List<Employee> items)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
foreach (var item in items)
{
if (item.IsNew == true)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
item.PayrollTypeID = (int)currentUser.PayrollTypeID;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
_EmployeeService.Save(item);
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpPost]
[Route("saveHrEmployee")]
public ActionResult SaveHrEmployee(HREmployee item)
{
List<HREmployee> items = new List<HREmployee>();
items.Add(item);
try
{
_hrEmployeeService.Save(items);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item.ID);
}
[HttpPost]
[Route("deleteChildData")]
public ActionResult DeleteChildData(dynamic data)
{
var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
int id = item["id"].ToObject<int>();
string tableName = (string) item["tableName"].ToObject<string>();
string columnName = (string) item["columnName"].ToObject<string>();
try
{
_hrEmployeeService.DeleteChildData(tableName, columnName, id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpPost]
[Route("saveEmployeeContact")]
public ActionResult saveEmployeeContact(EmpContact item)
{
try
{
item.ID = _hrEmployeeService.SaveContact(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item.ID);
}
[HttpPost]
[Route("saveEmployeeSpouce")]
public ActionResult saveEmployeeSpouce(EmpSpouse item)
{
try
{
item.ID = _hrEmployeeService.SaveSpouce(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item.ID);
}
[HttpPost]
[Route("saveEmployeechildren")]
public ActionResult saveEmployeechildren(EmpChildren item)
{
try
{
item.ID = _hrEmployeeService.Savechildren(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item.ID);
}
[HttpPost]
[Route("saveEmployeeAcademic")]
public ActionResult saveEmployeeAcademic(EmpAcademic item)
{
try
{
item.ID = _hrEmployeeService.SaveAcademic(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item.ID);
}
[HttpPost]
[Route("saveExperience")]
public ActionResult saveExperience(EmpExperience item)
{
try
{
item.ID = _hrEmployeeService.SaveExperience(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item.ID);
}
[HttpGet("getEmpExperiences/{empId}")]
public ActionResult GetEmpExperiences(int empId)
{
List<EmpExperience> empExperiences = null;
try
{
empExperiences = _hrEmployeeService.GetEmpExperiences(empId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(empExperiences);
}
[HttpGet]
[Route("getSearchEmployeesByEmpIds/{empIds}")]
public ActionResult GetSearchEmployeesByEmpIds(string empIds)
{
List<SearchEmployee> items = new List<SearchEmployee>();
List<int> empIdList = new List<int>();
var stringArray = empIds.Split(',');
foreach (var s in stringArray)
{
empIdList.Add(Int32.Parse(s));
}
try
{
items = _serachManager.GetSelectedSearchEmployee(empIdList);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
[HttpPost]
[Route("saveEployeeTraining")]
public ActionResult saveEployeeTraining(EmpTraining item)
{
try
{
item.ID = _hrEmployeeService.SaveEmpTraining(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item.ID);
}
[HttpPost]
[Route("saveHrPersonalInfo")]
public ActionResult saveHrPersonalInfo(HREmployee item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (item.IsNew == true)
{
item.PayrollTypeID = (int) currentUser.PayrollTypeID;
item.CreatedDate = DateTime.Today;
item.CreatedBy = currentUser.UserID;
}
else
{
item.ModifiedDate = DateTime.Today;
item.ModifiedBy = currentUser.UserID;
}
try
{
_hrEmployeeService.SavePersonalInfo(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item.ID);
}
[HttpGet]
[Route("getSearchEmployeebyid/{empid}")]
public ActionResult getSearchEmployeebyid(int empid)
{
SearchEmployee olist = new SearchEmployee();
try
{
olist = _serachManager.get(empid);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(olist);
}
[HttpGet]
[Route("getLineManager/{empid}")]
public ActionResult GetLineManager(int empid)
{
Employee item = new Employee();
if (empid == 0)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
empid = currentUser.EmployeeID.GetValueOrDefault();
}
try
{
item = _EmployeeService.GetLineManager(empid);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
[HttpGet]
[Route("getByLineManager/{empid}")]
public ActionResult GetByLineManager(int empid)
{
List<Employee> item = new List<Employee>();
if (empid == 0)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
empid = currentUser.EmployeeID.GetValueOrDefault();
}
try
{
item = _EmployeeService.GetSubordinatesByLineManager(empid);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
[HttpGet]
[Route("getSearchEmpbyLoginid")]
public ActionResult getSearchEmpbyLoginid()
{
SearchEmployee olist = new SearchEmployee();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
olist = _serachManager.get((int) currentUser.EmployeeID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(olist);
}
[HttpGet]
[Route("getMyTeamByLoginID")]
public ActionResult getMyTeamByLoginID()
{
List<SearchEmployee> items = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
items = _serachManager.GetTeam((int) currentUser.EmployeeID, EnumStatus.Active);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
[HttpGet]
[Route("getMyTeamByLoginIDForAttnReguApprove")]
public ActionResult getMyTeamByLoginIDForAttnReguApprove()
{
List<SearchEmployee> items = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
items = _serachManager.GetTeamForAttnReguApprove((int) currentUser.EmployeeID, EnumStatus.Active);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
[HttpPost]
[Route("getSelectedSearchEmployees")]
public ActionResult GetSelectedSearchEmployees(dynamic data)
{
List<SearchEmployee> items = new List<SearchEmployee>();
var empids = JsonConvert.DeserializeObject<List<int>>(data.dataList.ToString());
try
{
items = _serachManager.GetSelectedSearchEmployee(empids);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
[HttpPost]
[Route("getSearchEmployeesByIDs")]
public ActionResult getSearchEmployeesByIDs(dynamic data)
{
List<SearchEmployee> items = new List<SearchEmployee>();
var empids = JsonConvert.DeserializeObject<List<int>>(data.ToString());
try
{
items = _serachManager.GetSelectedSearchEmployee(empids);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
[HttpGet("GetEmployeeNotYetUser/{payrollTypeID}")]
public ActionResult GetEmployeeNotYetUser(int payrollTypeID)
{
List<SearchEmployee> items = new List<SearchEmployee>();
try
{
items = this._serachManager.GetEmployeeNotYetUser(payrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpGet("getEmpCodeName/{code}/{name}")]
public ActionResult getEmpCodeName(string code, string name)
{
code = GlobalFunctions.GetApiDefaultData(code);
name = GlobalFunctions.GetApiDefaultData(name);
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<SearchEmployee> olist = new List<SearchEmployee>();
try
{
olist = _serachManager.FindEmpCodeName((int) currentUser.PayrollTypeID, code, name);
//List<Grade> grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
//List<Designation> designations = new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
//List<Department> departments = new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
//olist.ForEach(x=>
//{
// var grd = grades.FirstOrDefault(d => d.ID == x.GradeID);
// if(grd != null) x.gradeName = grd.Name;
// var designation = designations.FirstOrDefault(d => d.ID == x.designationID);
// if (designation != null) x.designationName = designation.Name;
// var department = departments.FirstOrDefault(d => d.ID == x.DepartmentID);
// if (department != null) x.departmentName = department.Name;
//});
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(olist);
}
[HttpGet("getEmployeeAttachments/{empId}")]
public ActionResult GetEmployeeAttachments(int empId)
{
List<empFileupload> items = new List<empFileupload>();
try
{
items = _hrEmployeeService.GetAllAttachmentsById(empId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
[HttpGet("getEmployeeAttachmentByType/{empId}/{refId}/{type}")]
public ActionResult GetEmployeeAttachmentByType(int empId, int refId, enumEmpFileUploadType type)
{
empFileupload item = new empFileupload();
try
{
item = _hrEmployeeService.GetAttachmentsByType(empId, refId, type);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
[HttpGet("getHREmployeeID/{empid}")]
public ActionResult getHREmployeeID(int empid)
{
HREmployee ohrEmp = new HREmployee();
try
{
ohrEmp = this._hrEmployeeService.Get(empid);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ohrEmp);
/*this._hrEmployeeService.Get(empid)
var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
HREmployeeService service = new HREmployeeService();
string employeeNo = (string)item["employeeNo"].ToObject<string>();
/*employeeCode = (employeeCode == "undefined" || employeeCode == "null") ? string.Empty : employeeCode;
employeeName = (employeeName == "undefined" || employeeName == "null") ? string.Empty : employeeName;#1#
return service.GetEmployeeByCode(employeeNo);*/
}
[HttpGet("getHREmployee")]
public ActionResult GetHREmployee()
{
HREmployee item = new HREmployee();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int employeeId = currentUser.EmployeeID.GetValueOrDefault();
try
{
item = this._hrEmployeeService.Get(employeeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
[HttpGet("getCurrentEmployee")]
public ActionResult GetCurrentEmployee()
{
Employee item = new Employee();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int employeeId = currentUser.EmployeeID.GetValueOrDefault();
try
{
item = this._EmployeeService.Get(employeeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
[HttpGet("getEmployeeForDashboard")]
public ActionResult GetEmployeeForDashboard()
{
DataTable item = new DataTable();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int employeeId = currentUser.EmployeeID.GetValueOrDefault();
try
{
item = this._EmployeeService.GetEmployeeForDashboard(employeeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
[HttpGet("getUserForLandingPage")]
public ActionResult GetUserForLandingPage()
{
DataTable item = new DataTable();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int userId = currentUser.UserID;
try
{
item = this._EmployeeService.GetUserForLandingPage(userId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
/// <summary>
/// Function will return 'Employee' Object
/// </summary>
/// <param name="empid"></param>
/// <returns></returns>
[HttpGet("getEmployeeByID/{empid}")]
public ActionResult getEmployeeByID(int empid)
{
Employee ohrEmp = null;
try
{
ohrEmp = this._EmployeeService.Get(empid);
if (ohrEmp.LineManagerID != null)
{
Employee linemanager = this._EmployeeService.Get((int)ohrEmp.LineManagerID);
ohrEmp.LineManager = linemanager.Name;
ohrEmp.LineManagerNo = linemanager.EmployeeNo;
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ohrEmp);
}
/// <summary>
/// Function will return 'Employee' Object
/// </summary>
/// <param name="empid"></param>
/// <returns></returns>
[HttpGet("getLoginEmployee")]
public ActionResult getLoginEmployee()
{
Employee ohrEmp = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (currentUser.EmployeeID == null)
{
return StatusCode(StatusCodes.Status500InternalServerError, "Employee Not Found");
}
try
{
ohrEmp = this._EmployeeService.Get((int) currentUser.EmployeeID);
if(ohrEmp.DesignationID != null)
{
ohrEmp.DesignationName = _designationService.Get((int)ohrEmp.DesignationID).Name;
}
if(ohrEmp.DepartmentID != null)
{
ohrEmp.DepartmentName = _departmentService.Get((int)ohrEmp.DepartmentID).Name;
}
if(ohrEmp.LineManagerID != null)
{
Employee linemanager = this._EmployeeService.Get((int)ohrEmp.LineManagerID);
ohrEmp.LineManager = linemanager.Name;
ohrEmp.LineManagerNo = linemanager.EmployeeNo;
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ohrEmp);
}
// Employee Bank Account
[HttpGet("getAllBankAccount")]
public ActionResult GetAllBankAccount()
{
List<EmployeeBankAccount> employeeBankAccountList = new List<EmployeeBankAccount>();
try
{
employeeBankAccountList = _employeeBankAccountService.Get();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeBankAccountList);
}
[HttpGet("getBankAccount/{id}/{effectDate}/{payrollTypeID}")]
public ActionResult GetBankAccount(int id, DateTime effectDate, int payrollTypeID)
{
EmployeeBankAccount employeeBankAccount = new EmployeeBankAccount();
try
{
employeeBankAccount = _employeeBankAccountService.Get(id, effectDate, payrollTypeID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeBankAccount);
}
[HttpPost("getBankAccountByDate")]
public ActionResult GetBankAccountByDate(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeID = 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<EmployeeBankAccount> employeeBankAccountList = new List<EmployeeBankAccount>();
try
{
employeeBankAccountList = _employeeBankAccountService.GetByDate(fromDate, toDate, payrollTypeID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeBankAccountList);
}
[HttpGet("getBankAccountByEmpID/{EmpID}")]
public ActionResult getBankAccountByEmpID(int EmpID)
{
List<EmployeeBankAccount> employeeBankAccountList = new List<EmployeeBankAccount>();
try
{
employeeBankAccountList = _employeeBankAccountService.GetByEmployeeID(EmpID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeBankAccountList);
}
[HttpGet("getBankAccountByEmpIDAndType/{EmpID}/{AccountType}")]
public ActionResult getBankAccountByEmpIDAndType(int EmpID, int AccountType)
{
List<EmployeeBankAccount> employeeBankAccountList = new List<EmployeeBankAccount>();
try
{
employeeBankAccountList = _employeeBankAccountService.GetByEmployeeIDAndType(EmpID, AccountType);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeBankAccountList);
}
[HttpPost("saveEmpNominee")]
public ActionResult SaveEmpNominee(EmpNominee item)
{
int id = 0;
try
{
id = _hrEmployeeService.SaveEmpNominee(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(id);
}
[HttpPost("DeleteEmpNominee")]
public ActionResult DeleteEmpNominee(EmpNominee item)
{
try
{
_hrEmployeeService.DeleteChildData("EMPNOMINEE", "NOMINEEID", item.ID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpGet("getBankAccountById/{id}")]
public ActionResult GetBankAccountById(int id)
{
EmployeeBankAccount bankAccount = new EmployeeBankAccount();
try
{
bankAccount = _employeeBankAccountService.Get(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(bankAccount);
}
[HttpPost]
[Route("saveBankAccount")]
public ActionResult SaveBankAccount(EmployeeBankAccount bankAccount)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (bankAccount.IsNew)
{
bankAccount.CreatedBy = currentUser.UserID;
bankAccount.CreatedDate = DateTime.Today;
}
else
{
bankAccount.ModifiedBy = currentUser.UserID;
bankAccount.ModifiedDate = DateTime.Today;
}
try
{
_employeeBankAccountService.Save(bankAccount);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(bankAccount.ID);
}
[HttpPost]
[Route("deleteBankAccount")]
public ActionResult deleteBankAccount(EmployeeBankAccount bankAccount)
{
try
{
//CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
//if(bankAccount.EffectDate <= currentUser.LastPayProcessDate){}
_employeeBankAccountService.Delete(bankAccount.ID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
// Employee Cost Center
[HttpGet("getCostCenterById/{id}")]
public ActionResult GetCostCenterById(int id)
{
EmployeeCostCenter employeeCostCenter = new EmployeeCostCenter();
try
{
employeeCostCenter = _employeeCostCenterService.Get(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeCostCenter);
}
[HttpGet("getAllEmployeeCostCenter")]
public ActionResult GetAllEmployeeCostCenter()
{
List<EmployeeCostCenter> employeeCostCenters = new List<EmployeeCostCenter>();
try
{
employeeCostCenters = _employeeCostCenterService.Get();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeCostCenters);
}
[HttpGet("getCostCenterByEmpId/{id}")]
public ActionResult GetCostCenterByEmpId(int id)
{
List<EmployeeCostCenter> employeeCostCenters = new List<EmployeeCostCenter>();
try
{
employeeCostCenters = _employeeCostCenterService.GetByEmpID(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeCostCenters);
}
[HttpGet("getCostCenterByCCId/{id}")]
public ActionResult GetCostCenterByCCId(int id)
{
List<EmployeeCostCenter> employeeCostCenters = new List<EmployeeCostCenter>();
try
{
employeeCostCenters = _employeeCostCenterService.GetByCCID(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeCostCenters);
}
[HttpGet("getCostCenterByEmpIdCCId/{ccid}/{empId}")]
public ActionResult GetCostCenterByEmpIdCCId(int ccid, int empId)
{
List<EmployeeCostCenter> employeeCostCenters = new List<EmployeeCostCenter>();
try
{
employeeCostCenters = _employeeCostCenterService.GetByEmpIDCCID(ccid, empId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeCostCenters);
}
[HttpGet("getCurrentHeadCount/{departmentId}/{designationId}/{gradeId}")]
public ActionResult GetCurrentHeadCount(int departmentId, int designationId, int gradeId)
{
int empCount = 0;
try
{
empCount = _EmployeeService.GetCurrentHeadCount(departmentId, designationId, gradeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(empCount);
}
[HttpPost]
[Route("saveCostCenter")]
public ActionResult SaveCostCenter(EmployeeCostCenter costCenter)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (costCenter.IsNew)
{
costCenter.CreatedBy = currentUser.UserID;
costCenter.CreatedDate = DateTime.Today;
}
else
{
costCenter.ModifiedBy = currentUser.UserID;
costCenter.ModifiedDate = DateTime.Today;
}
try
{
_employeeCostCenterService.Save(costCenter);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(costCenter);
}
[HttpPost]
[Route("saveCostCenterList")]
public ActionResult SaveCostCenterList(List<EmployeeCostCenter> costCenters)
{
try
{
_employeeCostCenterService.Save(costCenters);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(costCenters);
}
[HttpPost]
[Route("deleteCostCenterById")]
public ActionResult DeleteCostCenterById(int id)
{
try
{
_employeeCostCenterService.Delete(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpGet("getCostCenterByMonthStartEnd/{start}/{end}/{payrollTypeId}")]
public ActionResult GetCostCenterByMonthStartEnd(DateTime start, DateTime end, int payrollTypeId)
{
List<EmployeeCostCenter> employeeCostCenters = new List<EmployeeCostCenter>();
try
{
employeeCostCenters = _employeeCostCenterService.GetByMonthStartEnd(start, end, payrollTypeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeCostCenters);
}
[HttpGet("getCostCenter/{costCenter}/{id}")]
public ActionResult GetCostCenter(List<EmployeeCostCenter> costCenters, int id)
{
List<EmployeeCostCenter> employeeCostCenters = new List<EmployeeCostCenter>();
try
{
employeeCostCenters = _employeeCostCenterService.Get(costCenters, id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeCostCenters);
}
// Hr DashBoard
[HttpGet("getMaritalStats")]
public ActionResult GetMaritalStats()
{
List<int> list = new List<int>();
try
{
list = _hrEmployeeService.GetMaritalStats();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(list);
}
[HttpGet("getEmployeeMaleAgeStat")]
public ActionResult GetEmployeeMaleAgeStat()
{
List<int> list = new List<int>();
try
{
list = _hrEmployeeService.GetEmployeeMaleStatByAge();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(list);
}
[HttpGet("getEmployeeFemaleAgeStat")]
public ActionResult GetEmployeeFemaleAgeStat()
{
List<int> list = new List<int>();
try
{
list = _hrEmployeeService.GetEmployeeFemaleStatByAge();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(list);
}
[HttpGet("getChildrenCount")]
public ActionResult GetChildrenCount()
{
List<dynamic> list = new List<dynamic>();
try
{
list = _hrEmployeeService.GetChildrenCount();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(list);
}
[HttpGet("getAcademicStat")]
public ActionResult GetAcademicStat()
{
List<dynamic> list = new List<dynamic>();
try
{
list = _hrEmployeeService.GetAcademicStat();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(list);
}
[HttpGet("getProfileCompletePercentage")]
public ActionResult GetProfileCompletePercentage()
{
int ans;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int empId = currentUser.EmployeeID.GetValueOrDefault();
try
{
ans = _hrEmployeeService.GetProfileCompletePercentage(empId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ans);
}
[HttpGet("getEmpBasicInfo/{empIds}")]
public ActionResult GetEmpBasicInfo(string empIds)
{
DataSet ds = new DataSet();
List<EmployeeBasicInfo> employeeBasicInfos = new List<EmployeeBasicInfo>();
try
{
ds = _EmployeeService.GetEmpBasicInfo(empIds);
var list = ds.Tables[0].AsEnumerable()
.Select(row => new EmployeeBasicInfo
{
EmployeeNo = row.Field<string>("EMPLOYEENO"),
Name = row.Field<string>("NAME"),
Gender = row.Field<int>("GENDER"),
RName = row.Field<string>("RName"),
BirthDate = row.Field<DateTime>("BIRTHDATE"),
JoiningDate = row.Field<DateTime>("JOININGDATE"),
// DateOfConfirmation = row.Field<DateTime>("DATEOFCONFIRMATION"),
MaritalStatusId = row.Field<int>("MARITALSTATUSID")
}).ToList();
employeeBasicInfos = list;
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(employeeBasicInfos);
}
[HttpGet("getAllEmps")]
public ActionResult GetAllEmps()
{
List<Employee> employeeList = new List<Employee>();
try
{
employeeList = _EmployeeService.GetAllEmps();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeList);
}
[HttpPost("uploadEmpFile")]
[AllowAnonymous]
public ActionResult uploadEmpFile()
{
empFileupload item = new empFileupload();
string base64String = "";
try
{
bool directoryUpload = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "attachments", "directoryupload");
var fdata = Request.Form.Files["empfile"];
//Upload Image
item.employeeID = Convert.ToInt32(Request.Form["empid"]);
item.referenceID = Convert.ToInt32(Request.Form["referenceid"]);
item.filetype = (enumEmpFileUploadType)Convert.ToInt32(Request.Form["filetype"]);
byte[] textAsBytes = null;
using (var ms = new MemoryStream())
{
fdata.CopyTo(ms);
item.fileData = ms.ToArray();
item.fileName = item.filetype.ToString() + $" {item.referenceID}{Path.GetExtension(fdata.FileName)}";
//byte[]
textAsBytes = ms.ToArray();
//this._hrEmployeeService.uplaodFile(item);
base64String = Convert.ToBase64String(textAsBytes);
}
if (directoryUpload)
{
PhotoPath photoPath = new PhotoPathService().Get().FirstOrDefault();
string employeeNo = (new EmployeeService().Get(item.employeeID)).EmployeeNo;
string TargetFolder = photoPath.EmployeePhoto;
if (photoPath != null)
{
string newFileName = "";
switch (item.filetype)
{
case enumEmpFileUploadType.photo:
newFileName = string.Format("Image-{0}.jpg", employeeNo);
break;
case enumEmpFileUploadType.signature:
newFileName = string.Format("Signature-{0}.jpg", employeeNo);
break;
//case enumEmpFileUploadType.NomineePicture:
// newFileName = string.Format("Image-{0}.jpg", employeeNo);
// break;
//case enumEmpFileUploadType.NomineeSignature:
// newFileName = string.Format("Image-{0}.jpg", employeeNo);
// break;
default:
break;
}
#region Employee Picture
if (fdata != null)
{
byte[] bytes = textAsBytes;
try
{
//For development test only
//TargetFolder = "C:\\Users\\mashfiq.EASE\\Desktop\\Echotex\\" + employeeNo;
if (!Directory.Exists(TargetFolder))
{
Directory.CreateDirectory(TargetFolder);
}
//string[] Files = Directory.GetFiles(TargetFolder);
string fullTargetPath = TargetFolder + "\\" + newFileName;
System.IO.File.WriteAllBytes(fullTargetPath, bytes);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
}
#endregion
}
}
else
{
this._hrEmployeeService.uplaodFile(item);
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(base64String);
}
[HttpPost("uploadEmpFileInProfileUpdate")]
[AllowAnonymous]
public ActionResult UploadEmpFileInProfileUpdate()
{
empFileupload item = new empFileupload();
string base64String = "";
try
{
var fdata = Request.Form.Files["empfile"];
//Upload Image
string extension = Path.GetExtension(fdata.FileName);
switch (extension)
{
case ".png":
case ".jpg":
case ".jpeg":
item.FileFormat = EnumFileFormat.Picture;
break;
case ".pdf":
item.FileFormat = EnumFileFormat.Pdf;
break;
default:
break;
}
item.fileName = Request.Form["fileName"] + extension;
item.employeeID = Convert.ToInt32(Request.Form["empid"]);
item.referenceID = Convert.ToInt32(Request.Form["referenceid"]);
item.filetype = (enumEmpFileUploadType) Convert.ToInt32(Request.Form["filetype"]);
using (var ms = new MemoryStream())
{
fdata.CopyTo(ms);
item.fileData = ms.ToArray();
byte[] textAsBytes = ms.ToArray();
this._hrEmployeeService.UplaodFileInProfileUpdate(item);
base64String = Convert.ToBase64String(textAsBytes);
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(base64String);
}
[HttpGet("GetCompanyImage")]
public ActionResult GetCompanyImage()
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
byte[] img = this._payrollTypeService.GetCompanyImage((int)currentUser.PayrollTypeID);
if (img != null)
{
string base64String = "";
if (img != null)
{
base64String = Convert.ToBase64String(img);
}
return Ok(base64String);
}
else return Ok("");
}
[HttpGet]
[Route("GetPayrollTypeNameByLoginID")]
public ActionResult GetPayrollTypeNameByLoginID()
{
string payrollType = string.Empty;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
payrollType = this._payrollTypeService.Get((int)currentUser.PayrollTypeID).CompanyName;
return Ok(payrollType);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
}
[HttpGet("GetuploadEmpFile/{empid}/{referenceid}/{filetype}")]
public ActionResult GetuploadEmpFile(int empid, int referenceid, enumEmpFileUploadType filetype)
{
empFileupload item = new empFileupload();
item = this._hrEmployeeService.getuploadedFile(empid, referenceid, filetype);
if (item != null)
{
byte[] textAsBytes = (byte[]) item.fileData;
string base64String = "";
if (item != null)
{
base64String = Convert.ToBase64String(textAsBytes);
}
return Ok(base64String);
}
else return Ok("");
}
[HttpGet("getUploadEmpFileInProfileUpdate/{empid}/{referenceid}/{filetype}")]
public ActionResult GetUploadEmpFileInProfileUpdate(int empid, int referenceid, enumEmpFileUploadType filetype)
{
empFileupload item = null;
item = this._hrEmployeeService.GetuploadedFileInProfileUpdate(empid, referenceid, filetype);
if (item == null)
return Ok();
var extension = Path.GetExtension(item.fileName);
if (extension == ".pdf")
return Ok(item);
byte[] textAsBytes = (byte[]) item.fileData;
string base64String = "";
item.fileData = Convert.ToBase64String(textAsBytes);
return Ok(item);
}
[HttpPost("getEmpDetailInfo")]
public ActionResult GetEmpDetailInfo(List<SearchEmployee> selectedEmps)
{
string empIds = SearchEmployee.getEmpID(selectedEmps);
DataSet ds = new DataSet();
List<EmployeeDetailInfo> items = new List<EmployeeDetailInfo>();
var companyNameObj = new SystemConfigarationService().GetconfigValue(EnumConfigurationType.Logic, "system", "company");
string companyName = Convert.ToString(companyNameObj);
try
{
ds = _EmployeeService.GetEmpDetailsView(empIds);
//SystemConfigarationService ocManager = ocManager.GetAllChildrenByParentNode(EnumConfigurationType.Logic, "department");
List<Department> oDepartment = new DepartmentService().GetAll();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
foreach (var row in ds.Tables[0].AsEnumerable())
{
EmployeeDetailInfo temp = new EmployeeDetailInfo ();
Employee emp = new EmployeeService().GetFromAll(row["EMPLOYEENO"].ToString(), (int)currentUser.PayrollTypeID);
Department tempDepartment = null;
if (emp!= null)
{
tempDepartment = emp.DepartmentID != null ? oDepartment.Find(item => item.ID == emp.DepartmentID) : null;
}
temp.EmployeeNo = row["EmployeeNo"] == null ? "" : row.Field<string>("EmployeeNo");
temp.Name = row["Name"] == null ? "" : row.Field<string>("Name");
temp.BasicSalary = row["BASICSALARY"] == null ? 0 : row.Field<Decimal>("BASICSALARY");
temp.GrossSalary = row["GrossSalary"] == null ? 0 : row.Field<Decimal>("GrossSalary");
temp.TaxAmount = row["TAXAMOUNT"] == null ? 0 : row.Field<Decimal>("TAXAMOUNT");
temp.FatherName = row["Fathername"] == null ? "" : row.Field<string>("Fathername");
temp.FatherOccupation =
row["FatherOccupation"] == null ? "" : row.Field<string>("FatherOccupation");
temp.MotherOccupation =
row["MotherOccupation"] == null ? "" : row.Field<string>("MotherOccupation");
temp.MotherName = row["MotherName"] == null ? "" : row.Field<string>("MotherName");
temp.Gender = row["Gender"] == null ? "" : row.Field<string>("Gender");
temp.BirthDate = row["BIRTHDATE"] == null ? null : row.Field<DateTime>("BIRTHDATE");
temp.BirthPlace = row["BIRTHPlace"] == null ? "" : row.Field<string>("BIRTHPlace");
temp.TinNo = row["TINNO"] == null ? "" : row.Field<string>("TINNO");
temp.JoiningDate = row["JOININGDATE"] == null
? null
: row.Field<DateTime>("JOININGDATE");
temp.EmailAddress = row["EMAILADDRESS"] == null ? "" : row.Field<string>("EMAILADDRESS");
temp.Category = row["Category"] == null ? "" : row.Field<string>("Category");
temp.Status = row["Status"] == null ? "" : row.Field<string>("Status");
temp.Location = row["Location"] == null ? "" : row.Field<string>("Location");
temp.Division = row["Division"] == null ? "" : row.Field<string>("Division");
temp.Company = row["Company"] == null ? "" : row.Field<string>("Company");
temp.Department = row["Department"] == null ? "" : row.Field<string>("Department");
temp.Section = row["Section"] == null ? "" : row.Field<string>("Section");
if (companyName == "SGS Bangladesh Limited")
{
temp.Sbu = row["Section"] == null ? "" : row.Field<string>("Section");
}
Department tire5 = null;
Department tire4 = null;
Department tire3 = null;
Department tire2 = null;
Department tire1 = null;
if (tempDepartment != null)
{
if (tempDepartment.ParentID != null)
{
for (int i = (int)tempDepartment.Tier; i > 0; i--)
{
if (i == 5)
{
tire5 = oDepartment.Find(x => x.ID == tempDepartment.ID);
}
if (i == 4)
{
if (tire5 != null)
{
tire4 = oDepartment.Find(x => x.ID == tire5.ParentID);
}
else
{
tire4 = oDepartment.Find(x => x.ID == tempDepartment.ID);
}
}
if (i == 3)
{
if (tire4 != null)
{
tire3 = oDepartment.Find(x => x.ID == tire4.ParentID);
}
else
{
tire3 = oDepartment.Find(x => x.ID == tempDepartment.ID);
}
}
if (i == 2)
{
if (tire3 != null)
{
tire2 = oDepartment.Find(x => x.ID == tire3.ParentID);
}
else
{
tire2 = oDepartment.Find(x => x.ID == tempDepartment.ID);
}
}
if (i == 1)
{
if (tire2 != null)
{
tire1 = oDepartment.Find(x => x.ID == tire2.ParentID);
}
else
{
tire1 = oDepartment.Find(x => x.ID == tempDepartment.ID);
}
}
}
}
temp.deptireOne = (tire1 == null) ? "" : tire1.Name;
temp.deptireTwo = (tire2 == null) ? "" : tire2.Name;
temp.deptireThree = (tire3 == null) ? "" : tire3.Name;
temp.deptireFour = (tire4 == null) ? "" : tire4.Name;
temp.deptireFive = (tire5 == null) ? "" : tire5.Name;
}
temp.Designation = row["DESIGNATION"] == null ? "" : row.Field<string>("DESIGNATION");
temp.Grade = row["GRADE"] == null ? "" : row.Field<string>("GRADE");
temp.Designation = row["DESIGNATION"] == null ? "" : row.Field<string>("DESIGNATION");
temp.Religion = row["Religion"] == null ? "" : row.Field<string>("Religion");
temp.MaritalStatus = row["MaritalStatus"] == null ? "" : row.Field<string>("MaritalStatus");
temp.MobileNo = row["MOBILENO"] == null ? "" : row.Field<string>("MOBILENO");
temp.VendorCode = row["VendorCode"] == null ? "" : row.Field<string>("VendorCode");
temp.DateOfConfirmation = row["DATEOFCONFIRMATION"].ToString() == string.Empty ? null : row.Field<DateTime>("DATEOFCONFIRMATION");
temp.NationalId = row["NATIONALID"] == null ? "" : row.Field<string>("NATIONALID");
temp.PassportNo = row["PassPortNo"] == null ? "" : row.Field<string>("PassPortNo");
temp.PhotoPath = row["PhotoPath"] == null ? "" : row.Field<string>("PhotoPath");
temp.BloodGroup = row["bloodgroup"] == null ? GlobalExtensions.BloodGroupToFriendlyName(EnumBloodGroup.None) : GlobalExtensions.BloodGroupToFriendlyName((EnumBloodGroup)row.Field<int>("bloodgroup"));
temp.LineManagerNo = row["LineManagerNo"] == null ? "" : row.Field<string>("LineManagerNo");
temp.LineManagerName = row["LineManagerName"] == null ? "" : row.Field<string>("LineManagerName");
temp.LineManagerEmail = row["LineManagerEmail"] == null ? "" : row.Field<string>("LineManagerEmail");
temp.LineManagerDes = row["LineManagerDes"] == null ? "" : row.Field<string>("LineManagerDes");
temp.LmDivision = row["lmDivision"] == null ? "" : row.Field<string>("lmDivision");
temp.LineManagerName = row["LineManagerName"] == null ? "" : row.Field<string>("LineManagerName");
temp.LmDepartment = row["lmDepartment"] == null ? "" : row.Field<string>("lmDepartment");
temp.EmpStatus = row["EmpStatus"] == null ? "" : row.Field<string>("EmpStatus");
if (row.Table.Columns.Contains("CostCenter"))
temp.CostCenter = row["CostCenter"] == null ? "" : row.Field<string>("CostCenter");
temp.Nationality = row["NATIONALITY"] == null ? "" : row.Field<string>("NATIONALITY");
temp.OutPayBank = row["OUTPayBank"] == null ? "" : row.Field<string>("OUTPayBank");
temp.OutPayBranch = row["OUTPayBranch"] == null ? "" : row.Field<string>("OUTPayBranch");
temp.OutPayAccountNo = row["OutPayAccountNo"] == null ? "" : row.Field<string>("OutPayAccountNo");
temp.AccountNo = (row.Field<string>("AccountNo") == null || row.Field<string>("AccountNo") == "") ? temp.OutPayAccountNo : row.Field<string>("ACCOUNTNO");
temp.Bank = (row.Field<string>("Bank") == null || row.Field<string>("Bank") == "") ? temp.OutPayBank : row.Field<string>("Bank");
temp.Branch = (row.Field<string>("Branch") == null || row.Field<string>("Branch") == "") ? temp.OutPayBranch : row.Field<string>("Branch");
items.Add(temp);
}
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(items);
}
[HttpPost("getEmpApiResponse")]
[AllowAnonymous]
public ActionResult GetEmpApiResponse(EmployeeApiInfo userData)
{
EmployeeApiInfo employeeApiInfo = _employeeApiInfo.Value;
List<Employee> employees = new List<Employee>();
List<EmpApiResponse> empApiResponses = new List<EmpApiResponse>();
List<Department> departments = new List<Department>();
List<Designation> designations = new List<Designation>();
List<Location> locations = new List<Location>();
List<Costcenter> costCenters = new List<Costcenter>();
try
{
if (!(userData.UserId == employeeApiInfo.UserId && userData.Password == employeeApiInfo.Password))
return BadRequest("UserId or Password Is Invalid");
employees = _EmployeeService.GetAllEmps();
departments = _departmentService.GetAll(1);
designations = _designationService.GetAllDesignation(1, EnumStatus.Active, String.Empty, String.Empty);
locations = _locationService.GetLocations();
costCenters = _costCenterService.Get();
foreach (var employee in employees)
{
var empApiResponse = new EmpApiResponse();
empApiResponse.EmpCode = employee.GeId;
empApiResponse.EmpDName = employee.ExtraField1;
empApiResponse.EmpFName = employee.FirstName;
empApiResponse.EmpLName = employee.LastName;
empApiResponse.EmpEmail = employee.EmailAddress;
empApiResponse.EmpMobile = employee.MobileNo;
empApiResponse.PayrollId = employee.EmployeeNo;
empApiResponse.GenderName = Enum.GetName(typeof(EnumGender), employee.Gender);
var dept = departments.Find(x => x.ID == employee.DepartmentID);
empApiResponse.DepartmentName = dept == null ? "" : dept.Name;
var designation = designations.Find(x => x.ID == employee.DesignationID);
empApiResponse.DesignationName = designation == null ? "" : designation.Name;
var lineManager = employees.Find((x => x.ID == employee.LineManagerID));
empApiResponse.LineManager = lineManager == null ? "" : lineManager.Name;
empApiResponse.BaseStation = Enum.GetName(typeof(EnumBaseStation), employee.ExtraField2);
empApiResponse.VendorCode = employee.VendorCode;
var costCenter = costCenters.Find(x => x.ID == employee.CrgId);
empApiResponse.CostCenterCode = costCenter == null ? "" : costCenter.Code;
empApiResponse.CostCenterName = costCenter == null ? "" : costCenter.Name;
empApiResponse.BaseStation = Enum.GetName(typeof(EnumBaseStation), employee.ExtraField2);
var location = locations.Find(x => x.ID == employee.LocationID);
empApiResponse.Location = location == null ? "" : location.Name;
empApiResponse.TypeName = employee.ExtraField3;
empApiResponse.EmpActive = Enum.GetName(typeof(EnumEmpStatus), employee.Status);
empApiResponse.MinValue = employee.ExtraField4;
empApiResponse.MaxValue = employee.ExtraField5;
empApiResponses.Add(empApiResponse);
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(empApiResponses);
}
[HttpPost("getEmployeesByEmpIDs")]
public ActionResult GetEmployeesByEmpIDs(dynamic data)
{
List<Employee> employeeList = new List<Employee>();
var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string empIds = (string) item["dataList"].ToObject<string>();
try
{
employeeList = _EmployeeService.GetByEmpIDs(empIds);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeList);
}
[HttpPost("updateBanglaInformation")]
public ActionResult updateBanglaInformation(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string empNo = (string)item["employeeNo"].ToObject<string>();
string banglaName = (string)item["banglaName"].ToObject<string>();
string banglaSpouseName = (string)item["banglaSpouseName"].ToObject<string>();
string banglaFathersName = (string)item["banglaFathersName"].ToObject<string>();
string banglaMothersName = (string)item["banglaMothersName"].ToObject<string>();
DateTime ModifiedDate = new DateTime();
ModifiedDate = DateTime.Today;
int ModifiedBy = currentUser.UserID;
List <object> employeBanglaInfo = new List<object>();
employeBanglaInfo.Add(empNo);
employeBanglaInfo.Add(banglaName);
employeBanglaInfo.Add(banglaSpouseName);
employeBanglaInfo.Add(banglaFathersName);
employeBanglaInfo.Add(banglaMothersName);
employeBanglaInfo.Add(ModifiedDate);
employeBanglaInfo.Add(ModifiedBy);
try
{
new EmployeeService().UpdateBanglaInformation(employeBanglaInfo);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpPost("updateBanglaContactInformation")]
public ActionResult updateBanglaContactInformation(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string employeeNo = (string)item["employeeNo"].ToObject<string>();
string presentPOInBangla = (string)item["presentPOInBangla"].ToObject<string>();
string presentAddressInBangla = (string)item["presentAddressInBangla"].ToObject<string>();
string parmanentPOInBangla = (string)item["parmanentPOInBangla"].ToObject<string>();
string permanentAddressInBangla = (string)item["permanentAddressInBangla"].ToObject<string>();
DateTime ModifiedDate = new DateTime();
ModifiedDate = DateTime.Today;
int ModifiedBy = currentUser.UserID;
List<object> employeBanglaInfo = new List<object>();
employeBanglaInfo.Add(employeeNo);
employeBanglaInfo.Add(presentPOInBangla);
employeBanglaInfo.Add(presentAddressInBangla);
employeBanglaInfo.Add(parmanentPOInBangla);
employeBanglaInfo.Add(permanentAddressInBangla);
employeBanglaInfo.Add(ModifiedDate);
employeBanglaInfo.Add(ModifiedBy);
try
{
new EmployeeService().UpdateBanglaContactInformation(employeBanglaInfo);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpGet("getEmployeeByIDforHNM/{empid}")]
public ActionResult getEmployeeByIDforHNM(int empid)
{
Employee ohrEmp = null;
try
{
ohrEmp = this._EmployeeService.GetEmployeeForHnm(empid);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ohrEmp);
}
[HttpPost("getEmployeeDetailByEmpIDs")]
public ActionResult GetEmployeeDetailByEmpIDs(dynamic data)
{
List<Employee> employeeList = new List<Employee>();
var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
string empIds = (string)item["dataList"].ToObject<string>();
try
{
employeeList = _EmployeeService.GetByEmpIDs(empIds);
int? payrolltypeid = null;
if (currentUser.PayrollTypeID != null)
payrolltypeid = (int)currentUser.PayrollTypeID;
if (payrolltypeid != null)
{
List<Grade> grades = new GradeService().Get(EnumStatus.Regardless, (int)payrolltypeid);
List<Designation> designations =
new DesignationService().Get(EnumStatus.Regardless, (int)payrolltypeid);
List<Department> departments =
new DepartmentService().Get(EnumStatus.Regardless, (int)payrolltypeid);
employeeList.ForEach(x =>
{
var grd = grades.FirstOrDefault(d => d.ID == x.GradeID);
if (grd != null) x.GradeName = grd.Name;
var designation = designations.FirstOrDefault(d => d.ID == x.DesignationID);
if (designation != null) x.DesignationName = designation.Name;
var department = departments.FirstOrDefault(d => d.ID == x.DepartmentID);
if (department != null) x.DepartmentName = department.Name;
});
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeList);
}
[HttpGet]
[Route("getDashBoardGraphData")]
public ActionResult GetDashBoardGraphData()
{
DataSet ds = new DataSet();
try
{
ds = _EmployeeService.GetDashBoardGraphData();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet]
[Route("getSelfServiceBasicData")]
public ActionResult GetSelfServiceBasicData()
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int employeeId = currentUser.EmployeeID.GetValueOrDefault();
DataSet ds = new DataSet();
try
{
ds = _EmployeeService.GetSelfServiceBasicData(employeeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds.Tables[0]);
}
[HttpGet]
[Route("getNomineesForEss/{employeeId}")]
public ActionResult GetSelfServiceBasicData(int employeeId)
{
DataTable dt = new DataTable();
try
{
dt = _hrEmployeeService.GetNomineesForEss(employeeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpGet]
[Route("getTrainingForEss/{employeeId}")]
public ActionResult GetTrainingForEss(int employeeId)
{
DataTable dt = new DataTable();
try
{
dt = _hrEmployeeService.GetTrainingForEss(employeeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpGet]
[Route("getSelfServiceContactData")]
public ActionResult GetSelfServiceContactData()
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int employeeId = currentUser.EmployeeID.GetValueOrDefault();
DataSet ds = new DataSet();
try
{
ds = _EmployeeService.GetSelfServiceContactData(employeeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds.Tables[0]);
}
[HttpGet]
[Route("getSelfServiceAcademic")]
public ActionResult GetSelfServiceAcademic()
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int employeeId = currentUser.EmployeeID.GetValueOrDefault();
DataSet ds = new DataSet();
try
{
ds = _hrEmployeeService.GetSelfServiceAcademic(employeeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds.Tables[0]);
}
[HttpGet]
[Route("getSelfServiceFamilyInfo")]
public ActionResult GetSelfServiceFamilyInfo()
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int employeeId = currentUser.EmployeeID.GetValueOrDefault();
DataSet ds = new DataSet();
try
{
ds = _hrEmployeeService.GetSelfServiceFamilyInfo(employeeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds);
}
[HttpGet]
[Route("getLandingPageData/{isEmployee}/{isLeave}/{isAttendance}")]
public ActionResult GetLandingPageData(int isEmployee, int isLeave, int isAttendance)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
DataSet ds = new DataSet();
try
{
ds = _EmployeeService.GetLandingPageData(isEmployee, isLeave, isAttendance, payrollTypeId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds.Tables[0]);
}
[HttpGet]
[Route("GetHolidayInfoForDashboard")]
public ActionResult GetHolidayInfoForDashboard()
{
DataSet ds = new DataSet();
try
{
ds = _EmployeeService.GetHolidayInfoForDashboard();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ds.Tables[0]);
}
[HttpGet("getOtEligibleEmployees")]
public ActionResult GetOtEligibleEmployees()
{
DataTable dt = new DataTable();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
dt = _EmployeeService.GetOtEligibleEmployees((int)currentUser.PayrollTypeID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpPost("getEmployeeConfirmationData")]
public ActionResult getEmployeeConfirmationData(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
DateTime fromDate = DateTime.Today;
DateTime toDate = DateTime.Today;
if (items["fromDate"] != null)
fromDate = (DateTime)items["fromDate"].ToObject<DateTime>();
if (items["toDate"] != null)
toDate = (DateTime)items["toDate"].ToObject<DateTime>();
List<EmployeeConfirmation> employeeConfirmations = new EmployeeConfirmationService().GetByDateRange(fromDate, toDate, (int)currentUser.PayrollTypeID);
return Ok(employeeConfirmations);
}
[HttpPost]
[Route("deleteEmployeeConfirmationData")]
public ActionResult DeleteEmployeeConfirmationData(EmployeeConfirmation item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault();
try
{
new EmployeeConfirmationService().Delete(item.ID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveEmployeeConfirmationData")]
public ActionResult SaveEmployeeConfirmationData(EmployeeConfirmation item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (item.IsNew == true)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
item.ConfirmDate = item.JoiningDate.AddMonths(item.Month + item.gradeConfirmDuration);
try
{
new EmployeeConfirmationService().Save(item);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpGet]
[Route("getMyTeam")]
public ActionResult GetMyTeam()
{
DataTable dt = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int id = currentUser.EmployeeID.GetValueOrDefault();
Employee oEmp = _EmployeeService.Get(id);
try
{
dt = _EmployeeService.GetMyTeam(oEmp);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpPost]
[Route("deletecordinator")]
public ActionResult deletecordinator(EmployeeCordinator empCordinator)
{
try
{
new EmployeeCordinatorService().Delete(empCordinator);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpGet]
[Route("GetCordinatorTeam")]
public ActionResult GetCordinatorTeam()
{
DataTable dt = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int id = currentUser.EmployeeID.GetValueOrDefault();
Employee oEmp = _EmployeeService.Get(id);
try
{
dt = _EmployeeService.GetCordinatorTeam(oEmp);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpGet]
[Route("getLiveEmployee")]
public ActionResult getLiveEmployee()
{
DataTable dt = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int id = currentUser.EmployeeID.GetValueOrDefault();
Employee oEmp = _EmployeeService.Get(id);
try
{
dt = _EmployeeService.GetEmployeeCount(oEmp);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpGet]
[Route("getEmpOrganogramInfo")]
public ActionResult getEmpOrganogramInfo()
{
DataTable dt = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
int id = currentUser.EmployeeID.GetValueOrDefault();
Employee oEmp = _EmployeeService.Get(id);
try
{
dt = _EmployeeService.GetEmpOrganogramInfo(oEmp);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpGet]
[Route("getEmpInfoForGateman/{ID}")]
public ActionResult getEmpInfoForGateman(int id)
{
//var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
//EnumGatePassStatus status = item["status"].ToObject<EnumGatePassStatus>();
//DateTime fromDate = item["fromDate"].ToObject<DateTime>();
//DateTime toDate = item["toDate"].ToObject<DateTime>();
//CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
DataTable dt = null;
try
{
dt = _EmployeeService.getEmpInfoForGateman(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpGet]
[Route("getupcomingConfirmation/{confirmMonth}")]
public ActionResult getEmpInfoForGateman(string confirmMonth)
{
DateTime salaryMonth = GlobalFunctions.GetApiDefaultDateData(confirmMonth);
DataTable dt = null;
try
{
dt = new EmployeeConfirmationService().GetUpComingConfirmation(salaryMonth);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dt);
}
[HttpGet("GetMaternityLeaveEmployee")]
public ActionResult GetMaternityLeaveEmployee()
{
List<Employee> employeeList = new List<Employee>();
DateTime fromDate = DateTime.Now.AddDays(-12), toDate = DateTime.Now; ;
try
{
employeeList = _EmployeeService.GetMaternityLeaveEmployee(fromDate, toDate);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeList);
}
[HttpPost]
[Route("GetMaternityLeaveEmployee")]
public ActionResult GetMaternityLeaveEmployee(dynamic data)
{
List<Employee> employeeList = new List<Employee>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
DateTime toDate = items.toDate;
DateTime fromDate = items.fromDate;
try
{
//_SchedularSetup = new SchedularSetupService().Get(statusValue, schedulerValue, fromDateValue, toDateValue);
employeeList = _EmployeeService.GetMaternityLeaveEmployee(fromDate, toDate);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employeeList);
}
[HttpGet]
[Route("GetCoordinatorList")]
public ActionResult GetCoordinatorList()
{
DataTable oData=null;
try
{
oData = new EmployeeCordinatorService().GetCoordinatorList();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oData);
}
[HttpGet]
[Route("GetEmployeeByCoordinator/{corID}")]
public ActionResult GetEmployeeByCoordinator(int corID)
{
List<EmployeeCordinator> employees = null;
try
{
employees = new EmployeeCordinatorService().Get(corID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employees);
}
[HttpGet]
[Route("GetEmployeeByCoordinatorID")]
public ActionResult GetEmployeeByCoordinatorID()
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<Employee> employees = null;
int id = (int)currentUser.EmployeeID;
try
{
employees = _EmployeeService.GetEmployeeByCoordinator(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employees);
}
[HttpGet]
[Route("GetLgoinCordinatorEmps")]
public ActionResult GetLgoinCordinatorEmps()
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<EmployeeCordinator> employees = null;
int id = (int)currentUser.EmployeeID;
try
{
employees = new EmployeeCordinatorService().Get(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(employees);
}
[HttpGet]
[Route("GetSchedulerData")]
public ActionResult GetSchedulerData()
{
List<SchedularSetup> _SchedularSetup = null;
try
{
_SchedularSetup = new SchedularSetupService().Get(EnumStatus.Active);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(_SchedularSetup);
}
[HttpPost]
[Route("GetSchedulerBasedOnType")]
public ActionResult GetSchedulerBasedOnType(dynamic data)
{
DataTable dataTable = null;
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
EnumSchedularType schedulerValue = items.scheduler;
bool statusValue = items.status;
DateTime toDateValue = items.toDate;
DateTime fromDateValue = items.fromDate;
try
{
//_SchedularSetup = new SchedularSetupService().Get(statusValue, schedulerValue, fromDateValue, toDateValue);
dataTable = new MailSenderErrorListService().GetMailHistory(statusValue, schedulerValue, fromDateValue, toDateValue);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(dataTable);
}
[HttpGet("getAuthorizedPerson")]
public ActionResult getAuthorizedPerson()
{
List<AuthorizedPerson> items = new List<AuthorizedPerson>();
try
{
AuthorizedPersonService AuthorizedPersonService = new AuthorizedPersonService();
items = AuthorizedPersonService.Get();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
[HttpGet("getProfilePermission")]
public ActionResult getProfilePermission()
{
List<string> items = new List<string>();
try
{
string hnmProfilePermission = new SystemConfigarationService().GetconfigStringValue(EnumConfigurationType.UI, "hrinterface", "hnmprofilenotneeded").ToString();
items = hnmProfilePermission.Split(',').ToList();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
[HttpGet("dashboardAttnRemoved")]
public ActionResult DashboardAttnRemoved()
{
bool attnRemove = false;
try
{
attnRemove = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.UI, "hrinterface", "dashboardattnremove");
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(attnRemove);
}
[HttpGet("hnmdropdownactive")]
public ActionResult hnmdropdownactive()
{
bool hnmdropdownactive = false;
try
{
hnmdropdownactive = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.UI, "hrinterface", "hnmdropdown");
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(hnmdropdownactive);
}
[HttpGet("generateEmployeeNo")]
public ActionResult GenerateEmployeeNo()
{
string code = "";
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
bool autoGenerate = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "employee", "codeautogenerate");
try
{
if(autoGenerate)
code = _EmployeeService.GetNextCode((int)currentUser.PayrollTypeID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(code);
}
[HttpGet]
[Route("getPFExceptionData")]
public ActionResult getPFExceptionData()
{
List<PFException> pfExceptions = new List<PFException>();
try
{
pfExceptions = new PFExceptionService().Get();
List<Employee> employees = new EmployeeService().GetAllEmps();
foreach(PFException item in pfExceptions)
{
item.EmployeeNo = employees.Find(x=> x.ID == item.EmployeeID).EmployeeNo;
item.EmployeeName = employees.Find(x => x.ID == item.EmployeeID).Name;
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(pfExceptions);
}
[HttpPost("updatePFExceptionData")]
public ActionResult updatePFExceptionData(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
int? id = item["PFExceptionID"].ToObject<int?>();
int employeeID = (int)item["employeeID"].ToObject<int>();
int? epfPercent = item["epfPercent"].ToObject<int?>();
int? epfAmount = item["epfAmount"].ToObject<int?>();
int? cpfPercent = item["cpfPercent"].ToObject<int?>();
int? cpfAmount = item["cpfAmount"].ToObject<int?>();
PFException pfException = new PFException();
pfException.ID = id==null?0:id.Value;
pfException.EmployeeID = employeeID;
pfException.EPFPercent = epfPercent==null ? 0 : epfPercent.Value;
pfException.EPFAmount = epfAmount == null ? 0 : epfAmount.Value;
pfException.CPFPercent = cpfPercent == null ? 0 : cpfPercent.Value;
pfException.CPFAmount = cpfAmount == null ? 0 : cpfAmount.Value;
pfException.CreatedBy = currentUser.UserID;
pfException.StartDate = DateTime.Now;
pfException.CreatedDate = DateTime.Now;
pfException.ModifiedDate = DateTime.Now;
pfException.ModifiedBy= currentUser.UserID;
try
{
new PFExceptionService().Save(pfException);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpGet]
[Route("deletePFExceptionById/{id}")]
public ActionResult deletePFExceptionById(int id)
{
try
{
new PFExceptionService().Delete(id);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
}
}