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; 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, 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 GetEmployees() //{ // EmployeeService service = new EmployeeService(); // return service.Get(); //} [HttpPost] [Route("getSearchEmployeeForCordinator")] public ActionResult getSearchEmployeeForCordinator(SearchManager omanager) { List olist = new List(); 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 olist = new List(); 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 datapermissions = new DataPermissionService().Get(currentUser.UserID, // (int)currentUser.PayrollTypeID); //if (datapermissions != null && datapermissions.Count != 0) //{ // List items = new List(); // 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 grades = new GradeService().Get(EnumStatus.Regardless, (int)payrolltypeid); // List designations = // new DesignationService().Get(EnumStatus.Regardless, (int)payrolltypeid); // List 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 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 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 employeeData = new List(); 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 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 items = new List(); 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(); string tableName = (string) item["tableName"].ToObject(); string columnName = (string) item["columnName"].ToObject(); 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 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 items = new List(); List empIdList = new List(); 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 item = new List(); 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 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 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 items = new List(); var empids = JsonConvert.DeserializeObject>(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 items = new List(); var empids = JsonConvert.DeserializeObject>(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 items = new List(); 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 olist = new List(); try { olist = _serachManager.FindEmpCodeName((int) currentUser.PayrollTypeID, code, name); //List grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); //List designations = new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); //List 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 items = new List(); 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(); /*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); } /// /// Function will return 'Employee' Object /// /// /// [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); } /// /// Function will return 'Employee' Object /// /// /// [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 employeeBankAccountList = new List(); 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 toDate = (DateTime)items["toDate"].ToObject(); List employeeBankAccountList = new List(); 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 employeeBankAccountList = new List(); 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 employeeBankAccountList = new List(); 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 employeeCostCenters = new List(); 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 employeeCostCenters = new List(); 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 employeeCostCenters = new List(); 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 employeeCostCenters = new List(); 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 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 employeeCostCenters = new List(); 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 costCenters, int id) { List employeeCostCenters = new List(); 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 list = new List(); try { list = _hrEmployeeService.GetMaritalStats(); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(list); } [HttpGet("getEmployeeMaleAgeStat")] public ActionResult GetEmployeeMaleAgeStat() { List list = new List(); try { list = _hrEmployeeService.GetEmployeeMaleStatByAge(); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(list); } [HttpGet("getEmployeeFemaleAgeStat")] public ActionResult GetEmployeeFemaleAgeStat() { List list = new List(); try { list = _hrEmployeeService.GetEmployeeFemaleStatByAge(); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(list); } [HttpGet("getChildrenCount")] public ActionResult GetChildrenCount() { List list = new List(); try { list = _hrEmployeeService.GetChildrenCount(); } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(list); } [HttpGet("getAcademicStat")] public ActionResult GetAcademicStat() { List list = new List(); 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 employeeBasicInfos = new List(); try { ds = _EmployeeService.GetEmpBasicInfo(empIds); var list = ds.Tables[0].AsEnumerable() .Select(row => new EmployeeBasicInfo { EmployeeNo = row.Field("EMPLOYEENO"), Name = row.Field("NAME"), Gender = row.Field("GENDER"), RName = row.Field("RName"), BirthDate = row.Field("BIRTHDATE"), JoiningDate = row.Field("JOININGDATE"), // DateOfConfirmation = row.Field("DATEOFCONFIRMATION"), MaritalStatusId = row.Field("MARITALSTATUSID") }).ToList(); employeeBasicInfos = list; } catch (Exception e) { return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } return Ok(employeeBasicInfos); } [HttpGet("getAllEmps")] public ActionResult GetAllEmps() { List employeeList = new List(); 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 selectedEmps) { string empIds = SearchEmployee.getEmpID(selectedEmps); DataSet ds = new DataSet(); List items = new List(); 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 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("EmployeeNo"); temp.Name = row["Name"] == null ? "" : row.Field("Name"); temp.BasicSalary = row["BASICSALARY"] == null ? 0 : row.Field("BASICSALARY"); temp.GrossSalary = row["GrossSalary"] == null ? 0 : row.Field("GrossSalary"); temp.TaxAmount = row["TAXAMOUNT"] == null ? 0 : row.Field("TAXAMOUNT"); temp.FatherName = row["Fathername"] == null ? "" : row.Field("Fathername"); temp.FatherOccupation = row["FatherOccupation"] == null ? "" : row.Field("FatherOccupation"); temp.MotherOccupation = row["MotherOccupation"] == null ? "" : row.Field("MotherOccupation"); temp.MotherName = row["MotherName"] == null ? "" : row.Field("MotherName"); temp.Gender = row["Gender"] == null ? "" : row.Field("Gender"); temp.BirthDate = row["BIRTHDATE"] == null ? null : row.Field("BIRTHDATE"); temp.BirthPlace = row["BIRTHPlace"] == null ? "" : row.Field("BIRTHPlace"); temp.TinNo = row["TINNO"] == null ? "" : row.Field("TINNO"); temp.JoiningDate = row["JOININGDATE"] == null ? null : row.Field("JOININGDATE"); temp.EmailAddress = row["EMAILADDRESS"] == null ? "" : row.Field("EMAILADDRESS"); temp.Category = row["Category"] == null ? "" : row.Field("Category"); temp.Status = row["Status"] == null ? "" : row.Field("Status"); temp.Location = row["Location"] == null ? "" : row.Field("Location"); temp.Division = row["Division"] == null ? "" : row.Field("Division"); temp.Company = row["Company"] == null ? "" : row.Field("Company"); temp.Department = row["Department"] == null ? "" : row.Field("Department"); temp.Section = row["Section"] == null ? "" : row.Field("Section"); if (companyName == "SGS Bangladesh Limited") { temp.Sbu = row["Section"] == null ? "" : row.Field("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("DESIGNATION"); temp.Grade = row["GRADE"] == null ? "" : row.Field("GRADE"); temp.Designation = row["DESIGNATION"] == null ? "" : row.Field("DESIGNATION"); temp.Religion = row["Religion"] == null ? "" : row.Field("Religion"); temp.MaritalStatus = row["MaritalStatus"] == null ? "" : row.Field("MaritalStatus"); temp.MobileNo = row["MOBILENO"] == null ? "" : row.Field("MOBILENO"); temp.VendorCode = row["VendorCode"] == null ? "" : row.Field("VendorCode"); temp.DateOfConfirmation = row["DATEOFCONFIRMATION"].ToString() == string.Empty ? null : row.Field("DATEOFCONFIRMATION"); temp.NationalId = row["NATIONALID"] == null ? "" : row.Field("NATIONALID"); temp.PassportNo = row["PassPortNo"] == null ? "" : row.Field("PassPortNo"); temp.PhotoPath = row["PhotoPath"] == null ? "" : row.Field("PhotoPath"); temp.BloodGroup = row["bloodgroup"] == null ? GlobalExtensions.BloodGroupToFriendlyName(EnumBloodGroup.None) : GlobalExtensions.BloodGroupToFriendlyName((EnumBloodGroup)row.Field("bloodgroup")); temp.LineManagerNo = row["LineManagerNo"] == null ? "" : row.Field("LineManagerNo"); temp.LineManagerName = row["LineManagerName"] == null ? "" : row.Field("LineManagerName"); temp.LineManagerEmail = row["LineManagerEmail"] == null ? "" : row.Field("LineManagerEmail"); temp.LineManagerDes = row["LineManagerDes"] == null ? "" : row.Field("LineManagerDes"); temp.LmDivision = row["lmDivision"] == null ? "" : row.Field("lmDivision"); temp.LineManagerName = row["LineManagerName"] == null ? "" : row.Field("LineManagerName"); temp.LmDepartment = row["lmDepartment"] == null ? "" : row.Field("lmDepartment"); temp.EmpStatus = row["EmpStatus"] == null ? "" : row.Field("EmpStatus"); if (row.Table.Columns.Contains("CostCenter")) temp.CostCenter = row["CostCenter"] == null ? "" : row.Field("CostCenter"); temp.Nationality = row["NATIONALITY"] == null ? "" : row.Field("NATIONALITY"); temp.OutPayBank = row["OUTPayBank"] == null ? "" : row.Field("OUTPayBank"); temp.OutPayBranch = row["OUTPayBranch"] == null ? "" : row.Field("OUTPayBranch"); temp.OutPayAccountNo = row["OutPayAccountNo"] == null ? "" : row.Field("OutPayAccountNo"); temp.AccountNo = (row.Field("AccountNo") == null || row.Field("AccountNo") == "") ? temp.OutPayAccountNo : row.Field("ACCOUNTNO"); temp.Bank = (row.Field("Bank") == null || row.Field("Bank") == "") ? temp.OutPayBank : row.Field("Bank"); temp.Branch = (row.Field("Branch") == null || row.Field("Branch") == "") ? temp.OutPayBranch : row.Field("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 employees = new List(); List empApiResponses = new List(); List departments = new List(); List designations = new List(); List locations = new List(); List costCenters = new List(); 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 employeeList = new List(); var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); string empIds = (string) item["dataList"].ToObject(); 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 banglaName = (string)item["banglaName"].ToObject(); string banglaSpouseName = (string)item["banglaSpouseName"].ToObject(); string banglaFathersName = (string)item["banglaFathersName"].ToObject(); string banglaMothersName = (string)item["banglaMothersName"].ToObject(); DateTime ModifiedDate = new DateTime(); ModifiedDate = DateTime.Today; int ModifiedBy = currentUser.UserID; List employeBanglaInfo = new List(); 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 presentPOInBangla = (string)item["presentPOInBangla"].ToObject(); string presentAddressInBangla = (string)item["presentAddressInBangla"].ToObject(); string parmanentPOInBangla = (string)item["parmanentPOInBangla"].ToObject(); string permanentAddressInBangla = (string)item["permanentAddressInBangla"].ToObject(); DateTime ModifiedDate = new DateTime(); ModifiedDate = DateTime.Today; int ModifiedBy = currentUser.UserID; List employeBanglaInfo = new List(); 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 employeeList = new List(); var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); string empIds = (string)item["dataList"].ToObject(); try { employeeList = _EmployeeService.GetByEmpIDs(empIds); int? payrolltypeid = null; if (currentUser.PayrollTypeID != null) payrolltypeid = (int)currentUser.PayrollTypeID; if (payrolltypeid != null) { List grades = new GradeService().Get(EnumStatus.Regardless, (int)payrolltypeid); List designations = new DesignationService().Get(EnumStatus.Regardless, (int)payrolltypeid); List 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(); if (items["toDate"] != null) toDate = (DateTime)items["toDate"].ToObject(); List 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(); //DateTime fromDate = item["fromDate"].ToObject(); //DateTime toDate = item["toDate"].ToObject(); //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 employeeList = new List(); 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 employeeList = new List(); 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 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 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 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 = 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 items = new List(); 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 items = new List(); 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 pfExceptions = new List(); try { pfExceptions = new PFExceptionService().Get(); List 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 employeeID = (int)item["employeeID"].ToObject(); int? epfPercent = item["epfPercent"].ToObject(); int? epfAmount = item["epfAmount"].ToObject(); int? cpfPercent = item["cpfPercent"].ToObject(); int? cpfAmount = item["cpfAmount"].ToObject(); 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(); } [HttpGet("getAllEmployeeNameAndNo")] public ActionResult getAllEmployeeNameAndNo() { DataTable dt = new DataTable(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { dt = new EmployeeService().GetEmployeeNameAndNo((int)currentUser.PayrollTypeID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(dt); } } }