using HRM.BO; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Data; using HRM.BO.Configuration; using Microsoft.Extensions.Options; using Newtonsoft.Json; using HRM.DA; using System.Linq; using static iTextSharp.text.pdf.AcroFields; using NPOI.SS.Formula.Functions; using System.IO; using Ease.Core.DataAccess; using Newtonsoft.Json.Linq; namespace HRM.UI.Controllers.Talent_Management { [Route("api/Pmp")] [ApiController] [Authorize] public class PmpController : ControllerBase { private readonly IEmployeeService _EmployeeService; private readonly IPMPProcessService _pmpProcessService; private readonly IObjectiveTypeService _objectiveTypeService; private readonly IOrganogramService _organogramService; private readonly IObjectiveCategoryService _objectiveCategoryService; private readonly IObjectiveCategoryGradesService _objectiveCategoryGradesService; private readonly IObjectiveService _objectiveService; private readonly IEmployeeService _employeeService; private readonly IObjectiveSetService _objectiveSetService; private readonly IObjectiveSetRemarksService _objectiveSetRemarksService; private readonly IAssesmentValueDetailsService _assesmentValueDetailsService; private readonly IAppraisalPointRatingService _appraisalPointRatingService; private readonly IAppraisalPointService _appraisalPointService; private readonly IEmpAppraisalRatingService _empAppraisalRatingService; private readonly IEmployeeAppraisalService _employeeAppraisalService; private readonly IYearEndValuesRatingService _yearEndValuesRatingService; private readonly IOptions _emailSettings; private readonly ICompetencyService _competencyService; private readonly IQuestionnaireService _questionnaireService; private readonly IPMPValueBehaviorService _pmpValueBehaviorService; private readonly IDevelopmentPlanService _developmentPlanService; private readonly ITrainingNeedAnalysisService _trainingNeedAnalysisService; private readonly IPMPValueBehaviorSettingService _pmpValueBehaviorSettingService; private readonly ISuccessionRoleService _successionRoleService; private readonly ISuccessionPlanningService _successionPlanningService; private readonly IPMPRatingService _pmpRatingService; private readonly IPMSObjectiveProgressService _pmsObjectiveProgressService; private readonly IPMSObjectiveProgressAttachmentService _pmsObjectiveProgressAttachmentService; public PmpController(IPMPProcessService pmpProcessService, IObjectiveTypeService objectiveTypeService, IOrganogramService organogramService, IObjectiveCategoryService objectiveCategoryService, IObjectiveCategoryGradesService objectiveCategoryGradesService, IObjectiveService objectiveService, IEmployeeService employeeService, IObjectiveSetService objectiveSetService, IObjectiveSetRemarksService objectiveSetRemarksService, IAssesmentValueDetailsService assesmentValueDetailsService, IAppraisalPointRatingService appraisalPointRatingService, IAppraisalPointService appraisalPointService, IEmpAppraisalRatingService empAppraisalRatingService, IEmployeeAppraisalService employeeAppraisalService, IYearEndValuesRatingService yearEndValuesRatingService, IOptions emailSettings, ICompetencyService competencyService, IQuestionnaireService questionnaireService, IPMPValueBehaviorService pmpValueBehaviorService, IDevelopmentPlanService developmentPlanService, ITrainingNeedAnalysisService trainingNeedAnalysisService, IEmployeeService empService, IPMPValueBehaviorSettingService pmpValueBehaviorSettingService, ISuccessionRoleService successionRoleService, ISuccessionPlanningService successionPlanningService, IPMPRatingService pmpRatingService, IPMSObjectiveProgressService pmsObjectiveProgressService, IPMSObjectiveProgressAttachmentService pmsObjectiveProgressAttachmentService) { _pmpProcessService = pmpProcessService; _objectiveTypeService = objectiveTypeService; _organogramService = organogramService; _objectiveCategoryService = objectiveCategoryService; _objectiveCategoryGradesService = objectiveCategoryGradesService; _objectiveService = objectiveService; _employeeService = employeeService; _objectiveSetService = objectiveSetService; _objectiveSetRemarksService = objectiveSetRemarksService; _assesmentValueDetailsService = assesmentValueDetailsService; _appraisalPointRatingService = appraisalPointRatingService; _appraisalPointService = appraisalPointService; _yearEndValuesRatingService = yearEndValuesRatingService; _emailSettings = emailSettings; _competencyService = competencyService; _questionnaireService = questionnaireService; _empAppraisalRatingService = empAppraisalRatingService; _employeeAppraisalService = employeeAppraisalService; _pmpValueBehaviorService = pmpValueBehaviorService; _developmentPlanService = developmentPlanService; _trainingNeedAnalysisService = trainingNeedAnalysisService; _pmpValueBehaviorSettingService = pmpValueBehaviorSettingService; _EmployeeService = empService; _successionRoleService = successionRoleService; _successionPlanningService = successionPlanningService; _pmpRatingService = pmpRatingService; _pmsObjectiveProgressService = pmsObjectiveProgressService; _pmsObjectiveProgressAttachmentService = pmsObjectiveProgressAttachmentService; } // PMPProcess [HttpGet] [Route("getAllPmpProcess")] public ActionResult GetAllPmpProcess() { List items = new List(); try { items = _pmpProcessService.Get(EnumStatus.Regardless); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getLatestPMSYear/{yearStatus}")] public ActionResult getLatestPMSYear(EnumPMPStatus yearStatus) { List items = new List(); PMPProcess ritem = null; try { items = _pmpProcessService.Get(yearStatus); if (items.Count > 0) { items.OrderBy(x => x.PmpYear); ritem = items[0]; } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ritem); } [HttpPost] [Route("savePmpProcess")] public ActionResult SavePmpProcess(PMPProcess item) { int ans; try { ans = _pmpProcessService.Save(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ans); } [HttpPost] [Route("deletePmpProcess")] public ActionResult DeletePmpProcess(PMPProcess item) { try { _pmpProcessService.Delete(item.ID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getCurrentYear")] public ActionResult GetCurrentYear() { PMPProcess item = new PMPProcess(); try { item = _pmpProcessService.GetCurrentPMPYear(false); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item); } [HttpGet] [Route("getPmpProcessByYear/{pmpYear}")] public ActionResult GetPmpProcessByYear(int pmpYear) { PMPProcess item = new PMPProcess(); try { item = _pmpProcessService.GetByYear(pmpYear); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item); } [HttpGet] [Route("getAllObjectiveTypes")] public ActionResult GetAllObjectiveTypes() { List items = new List(); try { items = _objectiveTypeService.Get(EnumStatus.Regardless); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getMaxTier")] public ActionResult GetMaxTier() { int ans = 0; try { ans = _organogramService.MaxTier(); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ans); } [HttpPost] [Route("saveObjectiveCategory")] public ActionResult SaveObjectiveCategoryGrade(ObjectiveCategory item) { try { this._objectiveCategoryService.Save(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } // ObjectiveCategoryGrades [HttpGet] [Route("getObjectiveCategoryGradesByPmpYearIdAndCategory/{pmpYearId}/{categoryId}")] public ActionResult GetObjectiveCategoryGradesByPmpYearIdAndCategory(int pmpYearId, int categoryId) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int payrollTypeID = currentUser.PayrollTypeID.GetValueOrDefault(); List items = new List(); try { //items = _objectiveCategoryGradesService.Get(pmpYearId, categoryId); items = _objectiveCategoryGradesService.Get(pmpYearId, categoryId, payrollTypeID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getByGradeId/{gradeId}/{pmpYearId}")] public ActionResult GetByGradeId(int gradeId, int pmpYearId) { List items = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int employeeId = currentUser.EmployeeID.GetValueOrDefault(); Employee employee = new Employee(); try { if (gradeId == 0) { employee = _employeeService.Get(employeeId); gradeId = employee.GradeID.GetValueOrDefault(); } items = _objectiveCategoryGradesService.GetByGradeId(gradeId, pmpYearId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } // Objective [HttpPost] [Route("saveObjective")] public ActionResult SaveObjective(Objective item) { int ans; CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int employeeId = currentUser.EmployeeID.GetValueOrDefault(); item.EmployeeID = employeeId; try { ans = this._objectiveService.Save(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ans); } [HttpPost] [Route("DeleteObjective")] public ActionResult DeleteObjective(Objective item) { try { this._objectiveService.Delete(item.ID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpPost] [Route("RemoveObjective")] public ActionResult RemoveObjective(Objective item) { try { this._objectiveService.UpdateObjectiveStatus(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(true); } [HttpGet] [Route("getForValidation/{empId}/{pmpYearId}/{objectiveTypeId}")] public ActionResult GetForValidation(int empId, int pmpYearId, int objectiveTypeId) { List items = new List(); try { items = _objectiveService.GetForValidation(empId, pmpYearId, objectiveTypeId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getObjectiveListByEmployeeId/{pmpYearId}/{employeeId}")] public ActionResult GetObjectiveListByEmployeeId(int pmpYearId, int employeeId) { List items = new List(); if (employeeId == 0) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); employeeId = currentUser.EmployeeID.GetValueOrDefault(); } try { items = _objectiveService.GetByEmployeeID(employeeId, pmpYearId, false); List objectiveIDsInt = new List(); items.ForEach(o => objectiveIDsInt.Add(o.ID) ); string objectiveIDs = String.Join(",", objectiveIDsInt); List unreadEmployeeMessage = objectiveIDs != string.Empty ?_pmsObjectiveProgressService.GetUnreadMessage(objectiveIDs) : null; items.ForEach(o => { o.UnreadEmployeeMessage = unreadEmployeeMessage.FindAll(uem => uem.ObjectiveID == o.ID && uem.IsEmployee); o.UnreadLMMessage = unreadEmployeeMessage.FindAll(uem => uem.ObjectiveID == o.ID && !uem.IsEmployee); }); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpPost] [Route("getObjectiveByEmpIds")] public ActionResult GetObjectiveByEmpIds(dynamic data) { List items = new List(); var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); string empIds = (string)item["ids"].ToObject(); int pmpYearId = item["selectedYear"].ToObject(); ; try { items = _objectiveService.GetByEmployeeID(empIds, pmpYearId, false); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } // ObjectiveSet [HttpGet] [Route("getObjectiveSetByEmpId/{pmpYearId}/{employeeId}")] public ActionResult GetObjectiveSetByEmpId(int pmpYearId, int employeeId) { ObjectiveSet item = new ObjectiveSet(); if (employeeId == 0) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); employeeId = currentUser.EmployeeID.GetValueOrDefault(); } try { item = _objectiveSetService.GetByEmployeeID(employeeId, pmpYearId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item); } [HttpPost] [Route("getObjectiveSetByEmpIds")] public ActionResult GetObjectiveSetByEmpIds(dynamic data) { List items = new List(); var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); string empIds = (string)item["ids"].ToObject(); int pmpYearId = item["selectedYear"].ToObject(); ; try { items = _objectiveSetService.GetByEmpIds(pmpYearId, empIds); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getAllObjectiveSet")] public ActionResult GetAllObjectiveSet() { List items = new List(); try { items = _objectiveSetService.Get(); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getObjective/{objectiveID}")] public ActionResult getObjective(int objectiveID) { Objective item = null; try { item = _objectiveService.Get(objectiveID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item); } [HttpGet] [Route("getObjectiveSetWithChild/{employeeId}/{pmpYearId}")] public ActionResult GetObjectiveSetWithChild(int employeeId, int pmpYearId) { ObjectiveSet item = new ObjectiveSet(); bool withMessage = true; if (employeeId == 0) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); employeeId = currentUser.EmployeeID.GetValueOrDefault(); } try { item = _objectiveSetService.GetObjectiveSetWithChild(employeeId, pmpYearId, withMessage); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item); } [HttpGet] [Route("getObjectiveSetByDepartment/{pmpYearId}")] public ActionResult GetObjectiveSetByDepartment(int pmpYearId) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int empId = currentUser.EmployeeID.GetValueOrDefault(); List items = new List(); Employee employee = null; try { employee = _employeeService.Get(empId); if (employee.DepartmentID == null) throw new Exception("No Department Found"); int deptId = employee.DepartmentID.GetValueOrDefault(); items = _objectiveSetService.GetObjectiveSetByDepartment(deptId, pmpYearId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpPost] [Route("saveObjectiveSet")] public ActionResult SaveObjectiveSet(ObjectiveSet item) { int ans; try { ans = _objectiveSetService.Save(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ans); } [HttpPost] [Route("ApproveObjectiveByLineManager")] public ActionResult ApproveObjectiveByLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.obLmComplete = EnumObjectiveFlowStatus.Agreed; item.obLmCompleteDate = DateTime.Today; try { EmployeeService empService = new EmployeeService(); Employee oemp = empService.Get(item.EmployeeID); Employee currEmp= null; Employee secondLM = null; if (oemp != null && oemp.EmailAddress == "") { throw new Exception($"Missing email for {oemp.Name}."); } if (currentUser.EmployeeID != null) { currEmp = empService.Get(currentUser.EmployeeID.GetValueOrDefault()); if(currEmp != null) { if (currEmp.LineManagerID != null && currEmp.LineManagerID != 0) { secondLM = empService.Get(currEmp.LineManagerID.GetValueOrDefault()); if (secondLM == null) { throw new Exception("Missing line manager."); } if (secondLM.EmailAddress == "") { throw new Exception($"Missing email for line manager {secondLM.Name}."); } } } } _objectiveSetService.ApproveObjectiveByLineManager(item, currentUser.UserID); //const data = { // employeeId: 0, // message: `${this.employee.employeeNo} - ${this.employee.name} has created objectives. // Please Review.`, // subject: `Please review the objectives of ${this.employee.employeeNo} - ${this.employee.name}`, //}; //const data = { // employeeId: employee.employeeID, // message: `Your line manager has reviewed your created objectives. Please check.`, // subject: `Your objectives have been reviewed and approved for the year 2025.` //}; if (oemp.EmailAddress != "") { EmailSettings emailSettings = _emailSettings.Value; PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = $"Confirmation of KPI Approval for {op.PmpYear:yyyy}"; mailSender.Body = $"

We are pleased to inform you that your line manager {currEmp.Name} has reviewed and approved your KPI for the year {op.PmpYear:yyyy}.

"; mailSender.ThreadSendMail(emailSettings); if (secondLM != null && secondLM.EmailAddress != "") { mailSender = new MailSender(); mailSender.AddTo(secondLM.EmailAddress); mailSender.Subject = $"KPI Approval Request:{oemp.EmployeeNo} - {oemp.Name} ({op.PmpYear:yyyy})"; mailSender.Body = $"

{oemp.EmployeeNo} - {currEmp.Name} has reviewed and approved the KPI of {oemp.Name} for the year {op.PmpYear:yyyy}. Please review and provide your approval at your earliest convenience.

"; mailSender.ThreadSendMail(emailSettings); } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("SubmitSecondLMassessment")] public ActionResult SubmitSecondLMassessment(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // item.YESecondLMComplete = EnumObjectiveFlowStatus.Agreed; item.YESecondLMCompleteDate = DateTime.Now; item.ObjectiveSetRemarks.ObjectiveSetID = item.ID; item.ObjectiveSetRemarks.YearEndSecondLMReviewDate = DateTime.Now; try { _objectiveSetService.SubmitSecondLMassessment(item, currentUser.UserID); Employee oemp = new EmployeeService().Get(item.EmployeeID); Employee lm = null; if (oemp.LineManagerID != null) lm = new EmployeeService().Get((int)oemp.LineManagerID); PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); EmailSettings emailSettings = _emailSettings.Value; if(item.YESecondLMComplete == EnumObjectiveFlowStatus.Agreed) { if (oemp.EmailAddress != "") { MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = "Your KPI for the year " + op.PmpYear.ToString("yyyy") + " has been reviewed and approved."; mailSender.Body = "

" + " Your N + 2 manager has reviewed and approved your KPI of the year " + op.PmpYear.ToString("yyyy") + "."; mailSender.ThreadSendMail(emailSettings); } if (lm != null && lm.EmailAddress != "") { MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = oemp.EmployeeNo + "-" + oemp.Name + "'s KPI has been reviewed and approved for the year of " + op.PmpYear.ToString("yyyy"); ; mailSender.Body = "

" + " N + 2 manager has reviewed and approved " + oemp.EmployeeNo + " - " + oemp.Name + "'s KPI of the year " + op.PmpYear.ToString("yyyy"); mailSender.ThreadSendMail(emailSettings); } } if(item.YESecondLMComplete == EnumObjectiveFlowStatus.Revert) { if (oemp.EmailAddress != "") { MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = "Your KPI for the year " + op.PmpYear.ToString("yyyy") + " has been reverted for revision."; mailSender.Body = "

" + " Your N + 2 manager has reviewed and reverted for revision your year-end assessment " + op.PmpYear.ToString("yyyy") + "."; mailSender.ThreadSendMail(emailSettings); } if (lm != null && lm.EmailAddress != "") { MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = oemp.EmployeeNo + "-" + oemp.Name + "'s KPI has been reviewed and approved for the year of " + op.PmpYear.ToString("yyyy"); ; mailSender.Body = "

" + " N + 2 manager has reviewed and approved " + oemp.EmployeeNo + " - " + oemp.Name + "'s KPI of the year " + op.PmpYear.ToString("yyyy"); mailSender.ThreadSendMail(emailSettings); } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("RevertObjectiveByLineManager")] public ActionResult RevertObjectiveByLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.obLmComplete = EnumObjectiveFlowStatus.Revert; item.obLmCompleteDate = DateTime.Today; try { _objectiveSetService.RevertObjectiveByLineManager(item, currentUser.UserID); Employee oemp = new EmployeeService().Get(item.EmployeeID); if (oemp.EmailAddress != "") { EmailSettings emailSettings = _emailSettings.Value; PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = "Your KPI for the year " + op.PmpYear.ToString("yyyy") + " has been reverted for revision."; mailSender.Body = "

" + " Your N + 1 manager has reverted your KPI of the year " + op.PmpYear.ToString("yyyy") + " for revision. Please make the necessary corrections and resubmit it. " ; mailSender.ThreadSendMail(emailSettings); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("RevertObjectiveBySecondLineManager")] public ActionResult RevertObjectiveBySecondLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.obSecondLmComplete = EnumObjectiveFlowStatus.Revert; item.obSecondLmCompleteDate = DateTime.Today; try { _objectiveSetService.RevertObjectiveBySecondLineManager(item, currentUser.UserID); Employee oemp = new EmployeeService().Get(item.EmployeeID); Employee lm = null; if(oemp.LineManagerID != null) lm = new EmployeeService().Get((int)oemp.LineManagerID); PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); EmailSettings emailSettings = _emailSettings.Value; if (oemp.EmailAddress != "") { MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = "Your KPI for the year " + op.PmpYear.ToString("yyyy") + " has been reverted for revision."; mailSender.Body = "

" + " Your N + 2 manager has reverted your KPI of the year" + op.PmpYear.ToString("yyyy") + " for revision. Please make the necessary corrections and resubmit it. "; mailSender.ThreadSendMail(emailSettings); } if (lm.EmailAddress != "") { MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = oemp.EmployeeNo + "-" + oemp.Name + "'s KPI has been reverted for revision for the year of " + op.PmpYear.ToString("yyyy"); ; mailSender.Body = "

" + " N + 2 manager has reverted " + oemp.Name + "'s KPI of the year" + op.PmpYear.ToString("yyyy"); mailSender.ThreadSendMail(emailSettings); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("SubmitObjectivetoLineManager")] public ActionResult SubmitObjectivetoLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.OBEmpComplete = EnumObjectiveFlowStatus.Submit; item.OBEmpCompleteDate = DateTime.Today; item.obLmComplete = EnumObjectiveFlowStatus.Not_Yet_Initiated; item.obSecondLmComplete = EnumObjectiveFlowStatus.Not_Yet_Initiated; try { _objectiveSetService.SubmitObjectivetoLineManager(item, currentUser.UserID); DataTable oemp = new EmployeeService().GetNameAndMailWithNoLock(item.EmployeeID); if (oemp !=null && oemp.Rows[0]["linemanageremail"].ToString() != "") { EmailSettings emailSettings = _emailSettings.Value; PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.Rows[0]["linemanageremail"].ToString()); mailSender.Subject = oemp.Rows[0]["employeeno"].ToString() + "-" + oemp.Rows[0]["name"].ToString() + " has submitted KPI for the year " + op.PmpYear.ToString("yyyy"); mailSender.Body = "

" +" Please reveiw the KPI of "+ oemp.Rows[0]["employeeno"].ToString() + "-" + oemp.Rows[0]["name"].ToString() + "

"; mailSender.ThreadSendMail(emailSettings); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("SubmitMidYearReviewtoLineManager")] public ActionResult SubmitMidYearReviewtoLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // item.MYEmpComplete = EnumObjectiveFlowStatus.Submit; item.MYEmpCompleteDate = DateTime.Today; item.MYLMComplete = EnumObjectiveFlowStatus.Not_Yet_Initiated; try { _objectiveSetService.SubmitMidYearReviewtoLineManager(item, currentUser.UserID); //const data = { // employeeId: 0, // message: `${this.employee.employeeNo} - ${this.employee.name} Has Submitted Mid-Year Objectives. // Please Review.`, // subject: `Please Review The Mid-Year Objectives Of ${this.employee.employeeNo} - ${this.employee.name}`, //}; if(item.MYEmpComplete != EnumObjectiveFlowStatus.Draft) { DataTable oemp = new EmployeeService().GetNameAndMailWithNoLock(item.lmID); if (oemp != null && oemp.Rows[0]["linemanageremail"].ToString() != "") { EmailSettings emailSettings = _emailSettings.Value; PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.Rows[0]["linemanageremail"].ToString()); mailSender.Subject = oemp.Rows[0]["employeeno"].ToString() + "-" + oemp.Rows[0]["name"].ToString() + " has submitted Mid-Year objectives assessment for the year " + op.PmpYear.ToString("yyyy"); mailSender.Body = "

" + " Please reveiw the Mid-Year objectives assessment of " + oemp.Rows[0]["employeeno"].ToString() + "-" + oemp.Rows[0]["name"].ToString() + "

"; mailSender.ThreadSendMail(emailSettings); } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("ApproveMidYearReviewByLineManager")] public ActionResult ApproveMidYearReviewByLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // item.MYLMComplete = EnumObjectiveFlowStatus.Agreed; item.MYLMCompleteDate = DateTime.Today; try { _objectiveSetService.ApproveMidYearReviewByLineManager(item, currentUser.UserID); //const employee = this.searchEmployees.find(x => x.employeeID === item.employeeID); //const data = { // employeeId: employee.employeeID, // message: `Your Line Manager Has Reviewed Your Mid-Year Objectives. // Please check.`, // subject: `Your Mid-Year Objectives Are Reviewed` //}; Employee oemp = new EmployeeService().Get(item.EmployeeID); if (oemp.EmailAddress != "") { EmailSettings emailSettings = _emailSettings.Value; PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = "Your Mid-Year objectives assessment has been reviewed and approved for year " + op.PmpYear.ToString("yyyy"); mailSender.Body = "

" + " Your line manager has reviewed and approved the Mid-Year objectives assessment for " + op.PmpYear.ToString("yyyy") + "

"; mailSender.ThreadSendMail(emailSettings); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("RevertMidYearReviewByLineManager")] public ActionResult RevertMidYearReviewByLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.MYLMCompleteDate = DateTime.Today; try { _objectiveSetService.RevertMidYearReviewByLineManager(item, currentUser.UserID); Employee oemp = new EmployeeService().Get(item.EmployeeID); if (oemp.EmailAddress != "") { EmailSettings emailSettings = _emailSettings.Value; PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = "Your Mid-Year objectives assessment for " + op.PmpYear.ToString("yyyy") + " has been reverted for revision."; mailSender.Body = "

" + " Your N + 1 manager has reverted your Mid-Year objectives assessment of the year " + op.PmpYear.ToString("yyyy") + " for revision. Please make the necessary corrections and resubmit it."; mailSender.ThreadSendMail(emailSettings); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("DraftYearEndReviewtoLineManager")] public ActionResult DraftYearEndReviewtoLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.YEEmpComplete = EnumObjectiveFlowStatus.Draft_For_Employee; item.YEEmpCompleteDate = DateTime.Now; try { _objectiveSetService.SubmitYearEndReviewtoLineManager(item, currentUser.UserID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("SubmitYearEndReviewtoLineManager")] public ActionResult SubmitYearEndReviewtoLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // item.YEEmpComplete = EnumObjectiveFlowStatus.Submit; item.YEEmpCompleteDate = DateTime.Today; try { _objectiveSetService.SubmitYearEndReviewtoLineManager(item, currentUser.UserID); //const data = { // employeeId: 0, // message: `${this.employee.employeeNo} - ${this.employee.name} has created objectives. // Please Review.`, // subject: `Please review the objectives of ${this.employee.employeeNo} - ${this.employee.name}`, //}; DataTable oemp = new EmployeeService().GetNameAndMailWithNoLock(item.lmID); if (oemp != null && oemp.Rows[0]["linemanageremail"].ToString() != "") { EmailSettings emailSettings = _emailSettings.Value; PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.Rows[0]["linemanageremail"].ToString()); mailSender.Subject = oemp.Rows[0]["employeeno"].ToString() + "-" + oemp.Rows[0]["name"].ToString() + " has submitted Year-End objectives assessment for the year " + op.PmpYear.ToString("yyyy"); mailSender.Body = "

" + " Please reveiw the Year-End objectives assessment of " + oemp.Rows[0]["employeeno"].ToString() + "-" + oemp.Rows[0]["name"].ToString() + "

"; mailSender.ThreadSendMail(emailSettings); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("ApproveYearEndReviewByLineManager")] public ActionResult ApproveYearEndReviewByLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // item.YELMComplete = EnumObjectiveFlowStatus.Agreed; item.YELMCompleteDate = DateTime.Today; try { _objectiveSetService.YearEndReviewByLineManager(item, currentUser.UserID); //const data = { // employeeId: 0, // message: `${this.employee.employeeNo} - ${this.employee.name} has created objectives. // Please Review.`, // subject: `Please review the objectives of ${this.employee.employeeNo} - ${this.employee.name}`, //}; if(item.YELmComplete != EnumObjectiveFlowStatus.Draft) { DataTable oemp = new EmployeeService().GetNameAndMailWithNoLock(item.lmID); if (oemp != null && oemp.Rows[0]["linemanageremail"].ToString() != "") { EmailSettings emailSettings = _emailSettings.Value; PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.Rows[0]["linemanageremail"].ToString()); mailSender.Subject = oemp.Rows[0]["employeeno"].ToString() + "-" + oemp.Rows[0]["name"].ToString() + " has reviewed your assessment " + op.PmpYear.ToString("yyyy"); mailSender.Body = "

" + " your year-end objectives assessment has been review by " + oemp.Rows[0]["employeeno"].ToString() + "-" + oemp.Rows[0]["name"].ToString() + "

"; mailSender.ThreadSendMail(emailSettings); } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("RevertYearEndReviewByLineManager")] public ActionResult RevertYearEndReviewByLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.YELMCompleteDate = DateTime.Today; try { _objectiveSetService.YearEndReviewByLineManager(item, currentUser.UserID); if(item.YELmComplete == EnumObjectiveFlowStatus.Revert) { Employee oemp = new EmployeeService().Get(item.EmployeeID); if (oemp.EmailAddress != "") { EmailSettings emailSettings = _emailSettings.Value; PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = "Your year-end assessment for the year " + op.PmpYear.ToString("yyyy") + " has been reverted for revision."; mailSender.Body = "

" + " Your N + 1 manager has reverted your year-end assessment of the year " + op.PmpYear.ToString("yyyy") + " for revision. Please make the necessary corrections and resubmit it. "; mailSender.ThreadSendMail(emailSettings); } //DataTable oemp = new EmployeeService().GetNameAndMailWithNoLock(item.lmID); //if (oemp != null && oemp.Rows[0]["linemanageremail"].ToString() != "") //{ // EmailSettings emailSettings = _emailSettings.Value; // PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); // MailSender mailSender = new MailSender(); // mailSender.AddTo(oemp.Rows[0]["linemanageremail"].ToString()); // mailSender.Subject = oemp.Rows[0]["employeeno"].ToString() + "-" + oemp.Rows[0]["name"].ToString() + " has reviewed your assessment " + op.PmpYear.ToString("yyyy"); // mailSender.Body = "

" + " your Year-end objectives assessment has been review by " + oemp.Rows[0]["employeeno"].ToString() + "-" + oemp.Rows[0]["name"].ToString() + "

"; // mailSender.ThreadSendMail(emailSettings); //} } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("DraftYearEndReviewByLineManager")] public ActionResult DraftYearEndReviewByLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.YELmComplete = EnumObjectiveFlowStatus.Draft; item.YELMCompleteDate = DateTime.Now; try { _objectiveSetService.YearEndReviewByLineManager(item, currentUser.UserID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("ApproveObjectiveBySecondLineManager")] public ActionResult ApproveObjectiveBySecondLineManager(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.obSecondLmComplete = EnumObjectiveFlowStatus.Agreed; item.obSecondLmCompleteDate = DateTime.Today; try { Employee oemp = new EmployeeService().Get(item.EmployeeID); if (oemp != null && oemp.EmailAddress == "") { throw new Exception($"Missing email for {oemp.Name}."); } _objectiveSetService.ApproveObjectiveBySecondLineManager(item, currentUser.UserID); if (oemp.EmailAddress != "") { EmailSettings emailSettings = _emailSettings.Value; PMPProcess op = this._pmpProcessService.GetByPMPProcessID(item.PMPYearID); MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = "Your objectives have been reviewed and approved for year " + op.PmpYear.ToString("yyyy"); mailSender.Body = "

" + " Your N+2 Manager has reviewed and approved the objectives for " + op.PmpYear.ToString("yyyy") + "

"; mailSender.ThreadSendMail(emailSettings); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("EndEditModeOfObjective")] public ActionResult EndEditModeOfObjective(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.IsEditing = false; item.ModifiedBy = currentUser.UserID; item.ModifiedDate = DateTime.Today; try { _objectiveSetService.EndEditModeOfObjective(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("StartEditModeOfObjective")] public ActionResult StartEditModeOfObjective(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.IsEditing = true; item.ModifiedBy = currentUser.UserID; item.ModifiedDate = DateTime.Today; try { _objectiveSetService.EndEditModeOfObjective(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getCurrentUserID")] public ActionResult GetCurrentUserID() { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); return Ok(currentUser.EmployeeID); } [HttpPost] [Route("saveObjectiveSetWithValuesAndIDP")] public ActionResult saveObjectiveSetWithValuesAndIDP(dynamic data) { var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); ObjectiveSet objectiveSet = (ObjectiveSet)items["objectiveSet"].ToObject(); JArray valuesSettingJsonArray_ = (JArray)items["valuesSetting"]; JArray developmentPlansJsonArray_ = (JArray)items["developmentPlans"]; List pmpValueBehaviorSetting = valuesSettingJsonArray_.ToObject>(); List developmentPlans = developmentPlansJsonArray_.ToObject>(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); foreach(var item in developmentPlans) item.EmployeeID = currentUser.EmployeeID.GetValueOrDefault(); int ans; try { TransactionContext tc = TransactionContext.Begin(true); if(pmpValueBehaviorSetting != null && pmpValueBehaviorSetting.Count > 0) new PMPValueBehaviorSettingService().DeleteByObjectiveSetID(tc, pmpValueBehaviorSetting[0].ObjectiveSetID); new PMPValueBehaviorSettingService().SaveBulk(tc, pmpValueBehaviorSetting); new DevelopmentPlanService().Save(tc, developmentPlans); ans = new ObjectiveSetService().Save(tc, objectiveSet); tc.End(); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ans); } [HttpPost] [Route("saveObjSetWithChild")] public ActionResult SaveObjSetWithChild(ObjectiveSet item) { try { _objectiveSetService.SaveWithChild(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getByPMPYear/{pmpYearId}/{empIds}")] public ActionResult GetByPMPYear(int pmpYearId, string empIds) { List items = new List(); try { items = _objectiveSetService.GetByPMPYear(pmpYearId, empIds); if(items != null) { foreach (ObjectiveSet item in items) { item.UnreadEmployeeMessage += _pmsObjectiveProgressService.GetUnreadEmployeeMessageCountByObjectiveSetID(item.ID); } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpPost] [Route("getByPMPYearEmpIds")] public ActionResult GetByPMPYear(dynamic data) { var jesonItem = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); int pmpYearId = jesonItem["pmpProcessID"].ToObject(); string empIds = (string)jesonItem["empIDs"].ToObject(); List items = new List(); try { items = _objectiveSetService.GetByPMPYear(pmpYearId, empIds); if(items != null) { foreach (ObjectiveSet item in items) { item.UnreadEmployeeMessage += _pmsObjectiveProgressService.GetUnreadEmployeeMessageCountByObjectiveSetID(item.ID); } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getObjectiveSetByPMPYear/{pmpYearId}")] public ActionResult GetObjectiveSetByPMPYear(int pmpYearId) { List items = new List(); try { items = _objectiveSetService.GetByPMPYear(pmpYearId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } // ObjectiveSetRemarks [HttpGet] [Route("getByObjectiveSetId/{objSetId}")] public ActionResult GetByObjectiveSetId(int objSetId) { ObjectiveSetRemarks item = new ObjectiveSetRemarks(); try { item = _objectiveSetRemarksService.GetByObjectiveSetID(objSetId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item); } // AssesmentValueDetails [HttpGet] [Route("getAllAssessmentDetails")] public ActionResult GetAllAssessmentDetails() { List items = new List(); try { items = _assesmentValueDetailsService.Get(EnumStatus.Regardless); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } // AppraisalPointRating [HttpGet] [Route("getAllAppraisalPointRating")] public ActionResult GetAllAppraisalPointRating() { List items = new List(); try { items = _appraisalPointRatingService.Get(); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getAllAppraisalPointRatings/{year}")] public ActionResult GetAllAppraisalPointRatings(DateTime year) { List items = new List(); try { items = _appraisalPointRatingService.Get(year); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getAllAppraisalPointRatingsTypeWise/{type}")] [Route("getAllAppraisalPointRatingsTypeWise/{type}/{year}")] public ActionResult getAllAppraisalPointRatingsTypeWise(EnumAppraisalPointType type, DateTime? year) { List items = new List(); try { items = _appraisalPointRatingService.Get(type, year); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpPost] [Route("saveAppraisalPointRating")] public ActionResult saveAppraisalPointRating(AppraisalPointRating oAppraisalPointRating) { int item; try { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); if (oAppraisalPointRating.IsNew == true) { oAppraisalPointRating.CreatedBy = currentUser.UserID; oAppraisalPointRating.CreatedDate = DateTime.Today; } else { oAppraisalPointRating.ModifiedBy = currentUser.UserID; oAppraisalPointRating.ModifiedDate = DateTime.Today; } item = _appraisalPointRatingService.Save(oAppraisalPointRating); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item); } [HttpPost] [Route("deleteAppraisalPointRatingbyId")] public ActionResult deleteAppraisalPointRatingbyId(AppraisalPointRating oAppraisalPointRating) { try { _appraisalPointRatingService.Delete(oAppraisalPointRating.ID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } // AppraisalPoint [HttpGet] [Route("getAllAppraisalPoint")] public ActionResult GetAllAppraisalPoint() { List items = new List(); try { items = _appraisalPointService.Get(EnumStatus.Regardless); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } // PMPRating [HttpGet] [Route("getAllPMPRating")] public ActionResult GetAllPMPRating() { List items = new List(); List processItems = _pmpProcessService.Get(EnumStatus.Regardless); try { items = new PMPRatingService().Get(EnumStatus.Regardless); foreach (PMPRating item in items) { if (item.PMPYearId > 0) item.PMPYear = processItems.FirstOrDefault(i => i.ID == item.PMPYearId).PmpYear; } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpPost] [Route("savePmpRating")] public ActionResult SavePmpRating(PMPRating item) { int ans; try { 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; } ans = new PMPRatingService().Save(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ans); } [HttpPost] [Route("deletePmpRating")] public ActionResult DeletePmpRating(PMPRating item) { try { new PMPRatingService().Delete(item.ID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getPMPRatingByTypeAndYear/{type}/{pmpYearId}")] public ActionResult GetPMPRatingByTypeAndYear(EnumPMPRatingType type, int pmpYearId) { List items = new List(); try { items = _pmpRatingService.GetPMPRatingByTypeAndYear(type, pmpYearId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } // Send Email [HttpPost] [Route("sendEmailForPMS")] public ActionResult SendEmailForPms(dynamic data) { var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); int empId = item["employeeId"].ToObject(); string message = (string)item["message"].ToObject(); string subject = (string)item["subject"].ToObject(); Employee employee = new Employee(); EmailSettings emailSettings = _emailSettings.Value; try { if (empId == 0) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); empId = currentUser.EmployeeID.GetValueOrDefault(); employee = _employeeService.GetLineManager(empId); } else { employee = _employeeService.Get(empId); } //const data = { // employeeId: 0, // message: `${this.employee.employeeNo} - ${this.employee.name} has created objectives. // Please Review.`, // subject: `Please review the objectives of ${this.employee.employeeNo} - ${this.employee.name}`, //}; MailSender mailSender = new MailSender(); mailSender.AddTo(employee.EmailAddress); mailSender.Subject = subject; mailSender.Body = "

" + message + "

"; mailSender.SendMail(emailSettings); System.Threading.Thread.Sleep(500); /*MailSender mailSender = new MailSender(); mailSender.AddTo("ikramul@celimited.com"); mailSender.Subject = "This is PMS Email"; mailSender.Body = "

" + message + "

"; mailSender.SendMail(emailSettings); System.Threading.Thread.Sleep(500);*/ } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("sendEmailForPmsMultiple")] public ActionResult SendEmailForPmsMultiple(dynamic data) { EmailSettings emailSettings = _emailSettings.Value; var employees = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data.list)); var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); string subject = (string)item["emailSubject"].ToObject(); string body = (string)item["emailBody"].ToObject(); try { foreach (var employee in employees) { MailSender mailSender = new MailSender(); mailSender.AddTo(employee.emailAddress.ToString()); mailSender.Subject = subject; mailSender.Body = "

" + body + "

"; mailSender.SendMail(emailSettings); System.Threading.Thread.Sleep(500); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("sendEmailNotification")] public ActionResult SendEmailNotification(dynamic data) { List employees = new List(); EmailSettings emailSettings = _emailSettings.Value; var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); string empIds = (string)item["empIds"].ToObject(); string subject = (string)item["emailSubject"].ToObject(); string body = (string)item["emailBody"].ToObject(); try { employees = _employeeService.GetByEmpIDs(empIds); foreach (var employee in employees) { MailSender mailSender = new MailSender(); mailSender.AddTo(employee.EmailAddress); mailSender.Subject = subject; mailSender.Body = "

" + body + "

"; mailSender.SendMail(emailSettings); System.Threading.Thread.Sleep(500); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getPmsLmGoalReport/{pmpYearId}")] public ActionResult GetPmsLmGoalReport(int pmpYearId) { DataSet ds = new DataSet(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int employeeId = currentUser.EmployeeID.GetValueOrDefault(); try { ds = _objectiveService.GetPmsLmGoalReport(pmpYearId, employeeId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ds); } [HttpGet] [Route("getPmsIndividualGoalData/{pmpYearId}")] public ActionResult GetPmsIndividualGoalData(int pmpYearId) { DataSet ds = new DataSet(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int employeeId = currentUser.EmployeeID.GetValueOrDefault(); try { ds = _objectiveService.GetPmsIndividualGoalData(pmpYearId, employeeId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ds); } [HttpPost] [Route("getPmsDataDepartmentWise")] public ActionResult GetPmsDataDepartmentWise(dynamic data) { DataSet ds = new DataSet(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); string empIds = (string)item["empIds"].ToObject(); int pmpYearId = item["pmsYear"].ToObject(); int employeeId = currentUser.EmployeeID.GetValueOrDefault(); try { if (empIds.Length > 0) { ds = _objectiveService.GetPmsDataEmployeeWise(pmpYearId, empIds); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ds); } #region Competency [HttpGet] [Route("getCompetencys")] public ActionResult getCompetencys() { List oCompetency = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault(); try { oCompetency = _competencyService.Get(EnumStatus.Regardless, payrollTypeId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oCompetency); } #endregion Competency #region Questionnaire [HttpGet] [Route("getQuestionnaires")] public ActionResult getQuestionnaires() { List oQuestionnaire = new List(); try { oQuestionnaire = _questionnaireService.Get(); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oQuestionnaire); } [HttpPost] [Route("saveQuestionnaires")] public ActionResult saveQuestionnaires(Questionnaire oQuestionnaire) { Questionnaire item = new Questionnaire(); oQuestionnaire.GradeIDsInString = string.Join(",", oQuestionnaire.GradeIDs.Select(x => x.ToString()).ToList()); try { item.ID = _questionnaireService.Save(oQuestionnaire); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item.ID); } [HttpPost] [Route("deleteQuestionnaireById")] public ActionResult deleteQuestionnaireById(Questionnaire oQuestionnaire) { try { _questionnaireService.Delete(oQuestionnaire.ID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } #endregion Questionnaire #region Calibration [HttpGet] [Route("getCalibrationByPmpYearId/{pmpYearId}")] public ActionResult GetCalibrationByPmpYearId(int pmpYearId) { List items = new List(); try { items = new CalibrationService().GetByPmpYearId(pmpYearId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getCalibrationByEmpIdAndPmpYearId/{empId}/{pmpYearId}")] public ActionResult GetCalibrationByEmpIdAndPmpYearId(int empId, int pmpYearId) { Calibration item = new Calibration(); try { item = new CalibrationService().GetByEmpIdAndPmpYearId(empId, pmpYearId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(item); } [HttpGet] [Route("getSubordinatesCalibration/{pmpYearId}")] public ActionResult GetSubordinatesCalibration(int pmpYearId) { List items = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int empId = currentUser.EmployeeID.GetValueOrDefault(); try { items = new CalibrationService().GetSubordinatesCalibration(pmpYearId, empId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpPost] [Route("saveCalibration")] public ActionResult SaveCalibration(Calibration item) { try { 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; } if (item.CalibrationAudiances.Count > 0) { foreach(CalibrationAudiance calibrationAudiance in item.CalibrationAudiances) if (calibrationAudiance.IsNew == true) { calibrationAudiance.CreatedBy = currentUser.UserID; calibrationAudiance.CreatedDate = DateTime.Today; } else { calibrationAudiance.ModifiedBy = currentUser.UserID; calibrationAudiance.ModifiedDate = DateTime.Today; } } new CalibrationService().Save(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("saveCalibrationEss")] public ActionResult SaveCalibrationEss(Calibration item) { try { 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; } new CalibrationService().SaveCalibrationEss(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("deleteCalibration")] public ActionResult DeleteCalibration(Calibration item) { try { new CalibrationService().Delete(item.ID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getEmployeeWithRatings/{pmpYearId}/{ratingStr}")] public ActionResult GetEmployeeWithRatings(int pmpYearId, string ratingStr) { DataSet ds = new DataSet(); try { ds = new CalibrationService().GetEmployeeWithRatings(pmpYearId, ratingStr); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ds.Tables[0]); } #endregion Calibration #region CalibrationAudiance [HttpGet] [Route("getCalibrationAudianceByCalibrationId/{calibrationId}")] public ActionResult getCalibrationAudianceByCalibrationId(int calibrationId) { List items = new List(); try { //items = new CalibrationAudianceService().Get(calibrationId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } #endregion #region PMPValueBehavior [HttpGet] [Route("getPMPValueBehaviors")] public ActionResult getPMPValueBehaviors() { List oPMPValueBehavior = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault(); try { oPMPValueBehavior = _pmpValueBehaviorService.Get(EnumStatus.Regardless); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oPMPValueBehavior); } [HttpGet] [Route("getPMPValueBehaviors/{pmpYearId}/{employeeId}")] public ActionResult getPMPValueBehaviors(int pmpYearId, int employeeId) { List oPMPValueBehaviors = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault(); List oPMPValueBehaviorSettings = null; DataRow oDR = null; DataTable oPMPValueBehaviorsDT = new DataTable(); oPMPValueBehaviorsDT.Columns.Add("Id", typeof(int)); oPMPValueBehaviorsDT.Columns.Add("PMPValueBehaviorSettingID", typeof(int)); oPMPValueBehaviorsDT.Columns.Add("Code", typeof(string)); oPMPValueBehaviorsDT.Columns.Add("Name", typeof(string)); oPMPValueBehaviorsDT.Columns.Add("Description", typeof(string)); oPMPValueBehaviorsDT.Columns.Add("Question", typeof(string)); oPMPValueBehaviorsDT.Columns.Add("ParentID", typeof(int)); oPMPValueBehaviorsDT.Columns.Add("Tier", typeof(int)); oPMPValueBehaviorsDT.Columns.Add("PayrollTypeID", typeof(int)); oPMPValueBehaviorsDT.Columns.Add("TargetRating", typeof(int)); oPMPValueBehaviorsDT.Columns.Add("EmpComments", typeof(string)); oPMPValueBehaviorsDT.Columns.Add("EmpCommentsDate", typeof(DateTime)); oPMPValueBehaviorsDT.Columns.Add("MyEmpRating", typeof(int)); oPMPValueBehaviorsDT.Columns.Add("MyEmpComments", typeof(string)); oPMPValueBehaviorsDT.Columns.Add("MyEmpCommentsDate", typeof(DateTime)); oPMPValueBehaviorsDT.Columns.Add("MyLMRating", typeof(int)); oPMPValueBehaviorsDT.Columns.Add("MyLMComments", typeof(string)); oPMPValueBehaviorsDT.Columns.Add("MyLMCommentDate", typeof(DateTime)); oPMPValueBehaviorsDT.Columns.Add("YeEmpRating", typeof(int)); oPMPValueBehaviorsDT.Columns.Add("YeEmpComments", typeof(string)); oPMPValueBehaviorsDT.Columns.Add("YeEmpCommentsDate", typeof(DateTime)); oPMPValueBehaviorsDT.Columns.Add("YeLMRating", typeof(int)); oPMPValueBehaviorsDT.Columns.Add("YeLMComments", typeof(string)); oPMPValueBehaviorsDT.Columns.Add("YeLMCommentDate", typeof(DateTime)); int count = 0; try { int maxTire = Convert.ToInt32(new SystemConfigarationService().GetconfigValue(EnumConfigurationType.Logic, "pmpvaluebehavior", "tier")); oPMPValueBehaviors = _pmpValueBehaviorService.Get(EnumStatus.Regardless); ObjectiveSet oObjectiveSet = _objectiveSetService.GetByEmployeeID(employeeId, pmpYearId); if (oObjectiveSet != null) { oPMPValueBehaviorSettings = _pmpValueBehaviorSettingService.GetByObjectiveSetID(oObjectiveSet.ID); } foreach (PMPValueBehavior item in oPMPValueBehaviors) { oDR = oPMPValueBehaviorsDT.NewRow(); oDR["Id"] = item.ID; oDR["Code"] = item.Code; oDR["Name"] = item.Name; oDR["Description"] = item.Description; oDR["Question"] = item.Question; if(item.ParentID != null) oDR["ParentID"] = item.ParentID; oDR["Tier"] = item.Tier; oDR["PayrollTypeID"] = item.PayrollTypeID; if (maxTire == item.Tier) { if (oPMPValueBehaviorSettings != null && oPMPValueBehaviorSettings.Count > 0) { foreach (PMPValueBehaviorSetting oPMPValueBehaviorSettingItem in oPMPValueBehaviorSettings) { if (item.ID == oPMPValueBehaviorSettingItem.PMPValueBehaviorID) { oDR["PMPValueBehaviorSettingID"] = oPMPValueBehaviorSettingItem.ID; oDR["TargetRating"] = oPMPValueBehaviorSettingItem.TargetRating; oDR["EmpComments"] = oPMPValueBehaviorSettingItem.EmpComments; if (oPMPValueBehaviorSettingItem.EmpCommentsDate != null) oDR["EmpCommentsDate"] = oPMPValueBehaviorSettingItem.EmpCommentsDate; //if(oPMPValueBehaviorSettingItem.MyEmpRating != null) // oDR["MyEmpRating"] = oPMPValueBehaviorSettingItem.MyEmpRating; if (oPMPValueBehaviorSettingItem.MyEmpComments != null) oDR["MyEmpComments"] = oPMPValueBehaviorSettingItem.MyEmpComments; if (oPMPValueBehaviorSettingItem.MyEmpCommentsDate != null) oDR["MyEmpCommentsDate"] = oPMPValueBehaviorSettingItem.MyEmpCommentsDate; //if(oPMPValueBehaviorSettingItem.MyLMRating != null) // oDR["MyLMRating"] = oPMPValueBehaviorSettingItem.MyLMRating; if (oPMPValueBehaviorSettingItem.MyLMComments != null) oDR["MyLMComments"] = oPMPValueBehaviorSettingItem.MyLMComments; if (oPMPValueBehaviorSettingItem.MyLMCommentDate != null) oDR["MyLMCommentDate"] = oPMPValueBehaviorSettingItem.MyLMCommentDate; if(oPMPValueBehaviorSettingItem.YeEmpRating != null) oDR["YeEmpRating"] = oPMPValueBehaviorSettingItem.YeEmpRating; if (oPMPValueBehaviorSettingItem.YeEmpComments != null) oDR["YeEmpComments"] = oPMPValueBehaviorSettingItem.YeEmpComments; if (oPMPValueBehaviorSettingItem.YeEmpCommentsDate != null) oDR["YeEmpCommentsDate"] = oPMPValueBehaviorSettingItem.YeEmpCommentsDate; if (oPMPValueBehaviorSettingItem.YeLMRating != null) oDR["YeLMRating"] = oPMPValueBehaviorSettingItem.YeLMRating; if (oPMPValueBehaviorSettingItem.YeLMComments != null) oDR["YeLMComments"] = oPMPValueBehaviorSettingItem.YeLMComments; if (oPMPValueBehaviorSettingItem.YeLMCommentDate != null) oDR["YeLMCommentDate"] = oPMPValueBehaviorSettingItem.YeLMCommentDate; } } } } oPMPValueBehaviorsDT.Rows.Add(oDR); count++; } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oPMPValueBehaviorsDT); } #endregion PMPValueBehavior #region DevelopmentPlan [HttpPost] [Route("saveDevelopmentPlan")] public ActionResult SaveDevelopmentPlan(DevelopmentPlan item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.EmployeeID = currentUser.EmployeeID.GetValueOrDefault(); int ans; try { ObjectiveSet objectiveSet = _objectiveSetService.GetByEmployeeID(item.EmployeeID, item.PMPYearID); if(objectiveSet != null) item.ObjectiveSetID = objectiveSet.ID; ans = _developmentPlanService.Save(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ans); } [HttpGet("deleteDevelopmentPlan/{id}")] public ActionResult DeleteDevelopmentPlan(int id) { try { _developmentPlanService.Delete(id); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getDevelopmentPlansEmployee/{pmpYearId}/{currentYear}")] public ActionResult GetDevelopmentPlan(int pmpYearId, bool currentYear) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int employeeId = currentUser.EmployeeID.GetValueOrDefault(); List items = null; try { if (currentYear) { ObjectiveSet objectiveSet = _objectiveSetService.GetByEmployeeID(employeeId, pmpYearId); if (objectiveSet != null) items = _developmentPlanService.GetByObjectiveSetId(objectiveSet.ID); } else { //items = _developmentPlanService.GetPreviousYears(employeeId, pmpYearId); items = _developmentPlanService.GetPreviousYears(employeeId, _pmpProcessService.GetByPMPProcessID(pmpYearId).PmpYear); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getDevelopmentPlansEmployee/{employeeId}/{pmpYearId}/{currentYear}")] public ActionResult GetDevelopmentPlan(int employeeId, int pmpYearId, bool currentYear) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); List items = null; try { if (currentYear) { ObjectiveSet objectiveSet = _objectiveSetService.GetByEmployeeID(employeeId, pmpYearId); if (objectiveSet != null) items = _developmentPlanService.GetByObjectiveSetId(objectiveSet.ID); } else { items = _developmentPlanService.GetPreviousYears(employeeId, pmpYearId); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } #endregion DevelopmentPlan #region PMPValueBehaviorSetting [HttpPost] [Route("savePMPValueBehaviorSetting")] public ActionResult SavePMPValueBehaviorSetting(List items) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); //item.EmployeeID = currentUser.EmployeeID.GetValueOrDefault(); int ans; try { //ObjectiveSet objectiveSet = _objectiveSetService.GetByEmployeeID(item.EmployeeID, item.PMPYearID); //item.ObjectiveSetID = objectiveSet.ID; //ans = _developmentPlanService.Save(item); _pmpValueBehaviorSettingService.Save(items); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } #endregion PMPValueBehaviorSetting [HttpGet] [Route("getTrainingNeedAnalysis/{pmpYearId}")] public ActionResult GetTrainingNeedAnalysis(int pmpYearId) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); List items = null; List employees = new List(); try { items = _developmentPlanService.GetByPmpYearId(pmpYearId); employees = _EmployeeService.GetAllEmps(); 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); items.ForEach(x => { var employee = employees.FirstOrDefault(d => d.ID == x.EmployeeID); x.EmployeeName = employee.Name; x.EmployeeNo = employee.EmployeeNo; var designation = designations.FirstOrDefault(d => d.ID == employee.DesignationID); if (designation != null) x.DesignationName = designation.Name; var department = departments.FirstOrDefault(d => d.ID == employee.DepartmentID); if (department != null) x.DepartmentName = department.Name; }); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getTrainingNeedAnalysisCount/{pmpYearId}")] public ActionResult GetTrainingNeedAnalysisCount(int pmpYearId) { DataSet ds = new DataSet(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int employeeId = currentUser.EmployeeID.GetValueOrDefault(); try { ds = _developmentPlanService.GetTrainingNeedAnalysisCount(pmpYearId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ds.Tables[0]); } [HttpGet] [Route("getsuccessionroles")] public ActionResult GetSuccessionRoles() { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); List roles = new List(); try { roles = _successionRoleService.Get(EnumStatus.Active, (int)currentUser.PayrollTypeID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(roles); } [HttpPost] [Route("saveSuccessionPlanning")] public ActionResult saveSuccessionPlanning(SuccessionPlanning item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // item.EmployeeID = currentUser.EmployeeID.GetValueOrDefault(); int ans; try { item.PlanningYear = DateTime.Now; item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Now; ans = _successionPlanningService.Save(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ans); } [HttpGet] [Route("getsuccessionplanning")] public ActionResult Getsuccessionplanning() { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); //List roles = new List(); List plannings = new List(); List employees = new List(); try { List designations = new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); employees = _employeeService.GetAllEmps(); plannings = _successionPlanningService.Get(); if (plannings != null && plannings.Count > 0) { foreach (SuccessionPlanning plan in plannings) { var employee = new Employee(); employee = employees.Find(x => x.ID == plan.EmployeeID); plan.EmployeeName = employee.Name; if (employee.Status == EnumEmployeeStatus.Discontinued) plan.IsDiscontinueEmployee = true; else plan.IsDiscontinueEmployee = false; plan.DesignationName= designations?.Find(y=>y.ID == employee.ID)?.Name; var successionOne = new Employee(); successionOne = employees.Find(x => x.ID == plan.SuccessorOneID); plan.SuccessionOneName = successionOne.Name; if (successionOne.Status == EnumEmployeeStatus.Discontinued) plan.IsDiscontinueOne = true; else plan.IsDiscontinueOne = false; plan.SuccessionOneDesignation = designations?.Find(y => y.ID == successionOne.ID)?.Name; var successionTwo = new Employee(); successionTwo = employees.Find(x => x.ID == plan.SuccessorTwoID); plan.SuccessionTwoName = successionTwo.Name; if (successionOne.Status == EnumEmployeeStatus.Discontinued) plan.IsDiscontinueTwo = true; else plan.IsDiscontinueTwo = false; plan.SuccessionTwoDesignation = designations?.Find(y => y.ID == successionTwo.ID)?.Name; } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(plannings); } [HttpPost] [Route("deleteSuccessionPlanning")] public ActionResult DeleteSuccessionPlanning(SuccessionPlanning item) { try { _successionPlanningService.Delete(item.ID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getSecondLineManagerData")] public ActionResult getSecondLineManagerData() { DataTable dt = new DataTable(); dt.Columns.Add("EmployeeId", typeof(int)); dt.Columns.Add("EmployeeNo", typeof(string)); dt.Columns.Add("EmployeeName", typeof(string)); dt.Columns.Add("LineManagerID", typeof(int)); dt.Columns.Add("LineManager", typeof(string)); dt.Columns.Add("EmpRating", typeof(double)); dt.Columns.Add("LmRating", typeof(double)); dt.Columns.Add("SecondLMObjRating", typeof(double)); dt.Columns.Add("SecondLMValueRating", typeof(double)); dt.Columns.Add("SecondLMRating", typeof(double)); dt.Columns.Add("YEEmpComplete", typeof(int)); dt.Columns.Add("YELMComplete", typeof(int)); dt.Columns.Add("yeSecondLMComplete", typeof(int)); dt.Columns.Add("YeTotalObjectiveEmpMark", typeof(double)); dt.Columns.Add("YeTotalObjectiveLmMark", typeof(double)); //List oEmployees = null; List myTeam = null; CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { List allEmployees = new EmployeeService().GetAllEmps(); //oEmployees = new SearchEmployeeService().GetTeam((int)currentUser.EmployeeID, EnumStatus.Active); List oEmployees = new EmployeeService().GetSubordinatesByLineManager((int)currentUser.EmployeeID).FindAll(x => x.Status == EnumEmployeeStatus.Live); myTeam = oEmployees.ToList(); foreach (Employee emp in oEmployees) { foreach (Employee item in allEmployees.FindAll(x => x.LineManagerID == emp.ID).FindAll(x => x.Status == EnumEmployeeStatus.Live)) { myTeam.Add(item); } } //PMPProcess oPMPProcess = _pmpProcessService.GetCurrentPMPYear(false); List oObjectiveSets = _objectiveSetService.GetByPMPYear(_pmpProcessService.GetCurrentPMPYear(false).ID, null); DataRow dr = null; int count = 0; foreach(Employee item in myTeam) { dr = dt.NewRow(); dr["EmployeeId"] = item.ID; dr["EmployeeNo"] = item.EmployeeNo; dr["EmployeeName"] = item.Name; if(item.LineManagerID != null) { dr["LineManagerID"] = item.LineManagerID; dr["LineManager"] = allEmployees.Find(x => x.ID == item.LineManagerID).Name; } ObjectiveSet objectiveSet = oObjectiveSets.Find(x => x.EmployeeID == item.ID); if(objectiveSet != null) { dr["EmpRating"] = objectiveSet.EMPRating; dr["LmRating"] = objectiveSet.LMRating; dr["YEEmpComplete"] = objectiveSet.YEEmpComplete; dr["YELMComplete"] = objectiveSet.YELmComplete; dr["yeSecondLMComplete"] = objectiveSet.YESecondLMComplete; dr["SecondLMObjRating"] = objectiveSet.SecondLMObjRating; dr["SecondLMValueRating"] = objectiveSet.SecondLMValueRating; dr["SecondLMRating"] = objectiveSet.SecondLMOverallRating; } dt.Rows.Add(dr); count++; } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(dt); } [HttpGet] [Route("getPMSObjectiveProgressHistory/{objectiveID}")] public ActionResult GetPMSObjectiveProgressHistory(int objectiveID) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); List items = new List(); try { items = _pmsObjectiveProgressService.GetByObjectiveID(objectiveID); if(items != null) { DataTable dt = new DataTable(); dt = _pmsObjectiveProgressAttachmentService.GetWithOutFileData(objectiveID); foreach (var item in items) { foreach (DataRow dr in dt.Rows) { item.PMSObjectiveProgressAttachment = new PMSObjectiveProgressAttachment(); item.PMSObjectiveProgressAttachment.ID = Convert.ToInt32(dr["PMSObjectiveProgressAttachmentID"]); item.PMSObjectiveProgressAttachment.PMSObjectiveProgressID = Convert.ToInt32(dr["PMSObjectiveProgressID"]); item.PMSObjectiveProgressAttachment.FileName = Convert.ToString(dr["FileName"]); item.PMSObjectiveProgressAttachment.UploadTime = Convert.ToDateTime(dr["UploadTime"]); item.PMSObjectiveProgressAttachment.FileType = Convert.ToInt32(dr["FileType"]); } } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items.OrderByDescending(item => item.UpdateTime).ToList()); } [HttpPost] [Route("savePMSObjectiveProgressHistory")] public ActionResult savePMSObjectiveProgressHistory(PMSObjectiveProgress item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int ans; try { item.UpdateTime = DateTime.Now; item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Now; ans = _pmsObjectiveProgressService.Save(item); item.ID = ans; _pmsObjectiveProgressService.SendMail(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ans); } [HttpPost] [Route("savePMSObjectiveProgressHistorys")] public ActionResult savePMSObjectiveProgressHistorys(List items) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { foreach(PMSObjectiveProgress item in items) { if (item.IsNew) { item.UpdateTime = DateTime.Now; item.CreatedBy = currentUser.UserID; item.CreatedDate = DateTime.Now; _pmsObjectiveProgressService.SendMail(item); } } _pmsObjectiveProgressService.Save(items); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("updateReadTimePMSObjectiveProgressHistorys")] public ActionResult UpdateReadTimePMSObjectiveProgressHistorys(List items) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { List newitems = new List(); foreach (PMSObjectiveProgress item in items) { if (!item.IsNew) { if (item.IsEmployee == true && item.AchivePercent > 0) { item.IsRead = false; item.ReadTime = DateTime.Now; } else { item.IsRead = true; item.ReadTime = DateTime.Now; } } } _pmsObjectiveProgressService.UpdateReadTime(items); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost("uploadPMSObjectiveProgressHistoryWithAttachment")] [AllowAnonymous] public ActionResult uploadPMSObjectiveProgressHistoryWithAttachment() { PMSObjectiveProgressAttachment item = new PMSObjectiveProgressAttachment(); string base64String = ""; try { var fdata = Request.Form.Files["fileData"]; //Upload Image item.PMSObjectiveProgressID= Convert.ToInt32(Request.Form["pmsObjectiveProgressID"]); item.FileName = Convert.ToString(Request.Form["fileName"]); item.FileType = Convert.ToInt32(Request.Form["filetype"]); string employeeNo = Convert.ToString(Request.Form["employeeNo"]); using (var ms = new MemoryStream()) { fdata.CopyTo(ms); item.FileData = ms.ToArray(); item.FileName = employeeNo.ToString() + "-" + fdata.FileName.ToString();//$" {Path.GetExtension(fdata.FileName)}"; item.UploadTime = DateTime.Now; byte[] textAsBytes = ms.ToArray(); this._pmsObjectiveProgressAttachmentService.Save(item); base64String = Convert.ToBase64String(textAsBytes); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(base64String); } [HttpGet("GetPMSObjectiveProgressHistoryWithAttachment/{pmsObjectiveProgressID}")] public ActionResult GetPMSObjectiveProgressHistoryWithAttachment(int pmsObjectiveProgressID) { PMSObjectiveProgressAttachment item = new PMSObjectiveProgressAttachment(); item = this._pmsObjectiveProgressAttachmentService.GetbyPMSObjectiveProgressID(pmsObjectiveProgressID); if (item != null) { byte[] textAsBytes = (byte[])item.FileData; string base64String = Convert.ToBase64String(textAsBytes); return Ok(item); } else return Ok(null); } [HttpGet("GetPMSObjectiveProgress/{pmsObjectiveProgressID}")] public ActionResult GetPMSObjectiveProgress(int pmsObjectiveProgressID) { PMSObjectiveProgress item = null; item = this._pmsObjectiveProgressService.Get(pmsObjectiveProgressID); return Ok(item); } [HttpGet("getOverAllProgress")] public ActionResult GetOverAllProgress() { DataSet ds = new DataSet(); try { PMPProcess currPMPProcess = _pmpProcessService.GetCurrentPMPYear(false); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int employeeId = currentUser.EmployeeID.GetValueOrDefault(); int totalteam = 0, progressEntered = 0, remaining = 0, over70 = 0, over50 = 0, over20 = 0, overallObjCompletion = 0; if (currPMPProcess != null) { List liveEmp = _employeeService.GetAllLive(); string empString = ""; List objectivesets = _objectiveSetService.GetByPMPYear(currPMPProcess.ID, empString); foreach (var objectiveset in objectivesets) { if(objectiveset.ProgressStatus > 0) { progressEntered++; } if(objectiveset.ProgressStatus > 20 && objectiveset.ProgressStatus <= 50) { over20++; } else if(objectiveset.ProgressStatus > 50 && objectiveset.ProgressStatus <= 70) { over50++; } else if(objectiveset.ProgressStatus > 70) { over70++; } } totalteam = liveEmp.Count; remaining = totalteam - progressEntered; DataTable dt = new DataTable(); dt.Columns.Add("teamCount", typeof(int)); dt.Columns.Add("progressEntered", typeof(int)); dt.Columns.Add("remaining", typeof(int)); dt.Columns.Add("over70", typeof(int)); dt.Columns.Add("over50", typeof(int)); dt.Columns.Add("over20", typeof(int)); dt.Columns.Add("overallObjCompletion", typeof(double)); DataRow oDr = dt.NewRow(); oDr["teamCount"] = totalteam; oDr["progressEntered"] = progressEntered; oDr["remaining"] = remaining; oDr["over70"] = over70; oDr["over50"] = over50; oDr["over20"] = over20; oDr["overallObjCompletion"] = overallObjCompletion; dt.Rows.Add(oDr); dt.TableName = "OverAllProgressData"; ds.Tables.Add(dt); DataTable empdata = new PMSObjectiveProgressService().GetEmpProgress(currPMPProcess.ID); empdata.TableName = "EmployeeData"; ds.Tables.Add(empdata); DataSet empProgressdata = new ObjectiveService().GetObjectiveByYear(currPMPProcess.ID); empProgressdata.Tables[0].TableName = "employeeProgressData"; DataTable empdatatest = empProgressdata.Tables[0].Copy(); ds.Tables.Add(empdatatest); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ds); } [HttpGet] [Route("getAllGradesWithNullableColor/{status}")] public ActionResult getAllGradesWithNullableColor(EnumStatus status) { List items = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault(); try { items = new GradeService().GetAllGradesWithNullableColor(payrollTypeId, status); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getKPIDashboardData/{pmpYearID}")] public ActionResult GetKPIDashboardData(int pmpYearID) { DataSet ds = new DataSet(); //Summary DataTable dt = new DataTable(); dt.Columns.Add("EmployeeID", typeof(int)); dt.Columns.Add("EmployeeNo", typeof(string)); dt.Columns.Add("EmployeeName", typeof(string)); dt.Columns.Add("JoiningDate", typeof(DateTime)); dt.Columns.Add("Designation", typeof(string)); dt.Columns.Add("Department", typeof(string)); dt.Columns.Add("Grade", typeof(string)); dt.Columns.Add("Employee", typeof(Employee)); dt.Columns.Add("PmpProcessID", typeof(int)); dt.Columns.Add("SelfRating", typeof(string)); dt.Columns.Add("N1Rating", typeof(string)); dt.Columns.Add("N2Rating", typeof(string)); dt.Columns.Add("SelfAchieve", typeof(double)); dt.Columns.Add("N1Achieve", typeof(double)); dt.Columns.Add("N2Achieve", typeof(double)); dt.Columns.Add("AchievePercent", typeof(double)); dt.Columns.Add("PerformanceRating", typeof(string)); //Detail DataTable dtDtl = new DataTable(); dtDtl.Columns.Add("EmployeeID", typeof(int)); dtDtl.Columns.Add("EmployeeNo", typeof(string)); dtDtl.Columns.Add("EmployeeName", typeof(string)); dtDtl.Columns.Add("JoiningDate", typeof(DateTime)); dtDtl.Columns.Add("Designation", typeof(string)); dtDtl.Columns.Add("Department", typeof(string)); dtDtl.Columns.Add("Grade", typeof(string)); dtDtl.Columns.Add("Type", typeof(string)); dtDtl.Columns.Add("KPIStatement", typeof(string)); dtDtl.Columns.Add("Target", typeof(string)); dtDtl.Columns.Add("Weightage", typeof(double)); dtDtl.Columns.Add("SelfAchive", typeof(double)); dtDtl.Columns.Add("SelfRemarks", typeof(string)); dtDtl.Columns.Add("N1Achive", typeof(double)); dtDtl.Columns.Add("N1Remarks", typeof(string)); dtDtl.Columns.Add("N2Achive", typeof(double)); dtDtl.Columns.Add("N2Remarks", typeof(string)); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int payrolltypeID = currentUser.PayrollTypeID.GetValueOrDefault(); try { List pmpYears = _pmpProcessService.Get(EnumStatus.Regardless); List objectiveTypes = _objectiveTypeService.Get(EnumStatus.Active, payrolltypeID); PMPProcess currPmpyear = _pmpProcessService.GetByPMPProcessID(pmpYearID); List oObjectiveSets = _objectiveSetService.GetByPMPYear(pmpYearID, payrolltypeID); List oObjectives = _objectiveService.GetByPMPYear(pmpYearID, payrolltypeID); List allEmployees = new EmployeeService().Get(EnumEmployeeStatus.Live, payrolltypeID); List designations = new DesignationService().Get(EnumStatus.Regardless, payrolltypeID); List departments = new DepartmentService().Get(EnumStatus.Regardless, payrolltypeID); List grades = new GradeService().Get(EnumStatus.Regardless, payrolltypeID); List objectiveratings = new PMPRatingService().GetPMPRatingByTypeAndYear(EnumPMPRatingType.Objective, pmpYearID); DataRow dr = null, drow = null; int count = 0; foreach (ObjectiveSet item in oObjectiveSets) { Employee employee = allEmployees.Find(x => x.ID == item.EmployeeID); if (employee != null) { #region Summary dr = dt.NewRow(); dr["Employee"] = employee; dr["EmployeeID"] = employee.ID; dr["EmployeeNo"] = employee.EmployeeNo; dr["EmployeeName"] = employee.Name; dr["JoiningDate"] = employee.JoiningDate; var des = designations.Find(d => d.ID == employee.DesignationID); if (des != null) dr["Designation"] = des.Name; var dep = departments.Find(d => d.ID == employee.DepartmentID); if (dep != null) dr["Department"] = dep.Name; var g = grades.Find(g => g.ID == employee.GradeID); if (g != null) dr["Grade"] = g.Name; dr["PmpProcessID"] = item.PMPYearID; var empRating = objectiveratings.Find(or => or.RatingValue == item.EMPObjRating); if (empRating != null) dr["SelfRating"] = empRating.Name; var lmRating = objectiveratings.Find(or => or.RatingValue == item.LMObjRating); if (lmRating != null) dr["N1Rating"] = lmRating.Name; var slmRating = objectiveratings.Find(or => or.RatingValue == item.SecondLMObjRating); if (slmRating != null) dr["N2Rating"] = slmRating.Name; if (item.EMPObjAchive != 0) dr["SelfAchieve"] = item.EMPObjAchive; if (item.LMObjAchive != 0) dr["N1Achieve"] = item.LMObjAchive; if (item.SecondLMAchive != 0) dr["N2Achieve"] = item.SecondLMAchive; if (item.OverallOBAchive != 0) dr["AchievePercent"] = item.OverallOBAchive; var pRating = objectiveratings.Find(or => or.RatingValue == item.OverallOBRating); if (pRating != null) dr["PerformanceRating"] = pRating.Name; dt.Rows.Add(dr); #endregion #region Detail List empoObjectives = oObjectives.FindAll(o => o.ObjectiveSetID == item.ID).OrderBy(o=>o.KPIType).ToList(); foreach(Objective obj in empoObjectives) { drow = dtDtl.NewRow(); drow["EmployeeID"] = employee.ID; drow["EmployeeNo"] = employee.EmployeeNo; drow["EmployeeName"] = employee.Name; drow["JoiningDate"] = employee.JoiningDate; if (des != null) drow["Designation"] = des.Name; if (dep != null) drow["Department"] = dep.Name; if (g != null) drow["Grade"] = g.Name; if (obj.KPIType == EnumObjectiveType.KPI) { drow["Type"] = "KPI"; } else if (obj.KPIType == EnumObjectiveType.Leadership) { drow["Type"] = "Leadership"; } drow["Weightage"] = obj.Weightages; var objType = objectiveTypes.Find(ot=> ot.ID == obj.ObjectiveType); if (objType != null) { drow["KPIStatement"] = objType.Name; } drow["SelfAchive"] = obj.YEEmpMark; drow["SelfRemarks"] = obj.YEEmployeeComments; drow["N1Achive"] = obj.YELMMark; drow["N1Remarks"] = obj.YELMComments; drow["N2Achive"] = obj.YESecondLMMark; drow["N2Remarks"] = obj.YESecondLMComments; dtDtl.Rows.Add(drow); } #endregion } } dt.TableName = "KpiSummary"; ds.Tables.Add(dt); dtDtl.TableName = "KpiDetail"; ds.Tables.Add(dtDtl); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(ds); } #region IDP (Independent Development Plan) [HttpGet("getObjectiveSetForIDPLineManager/{pmpYID}/{isFirstLM}")] public ActionResult GetObjectiveSetForIDPLineManager(int pmpYID, bool isFirstLM) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); DataTable dt = new DataTable(); try { dt = _objectiveSetService.GetByLineManagerID(pmpYID, isFirstLM, (int)currentUser.EmployeeID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(dt); } [HttpGet("GetObjectiveSetForCurrentEmployee/{pmpYID}/{isEmployee}")] public ActionResult GetObjectiveSetForCurrentEmployee(int pmpYID, bool isEmployee) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); DataTable dt = new DataTable(); try { dt = _objectiveSetService.GetByLoggedInEmployee(pmpYID, isEmployee, (int)currentUser.EmployeeID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(dt); } [HttpGet] [Route("UpdateLineManagerRemarks/{objectivesetid}/{remarks}")] public ActionResult UpdateLineManagerRemarks(int objectivesetid, string remarks) { try { _objectiveSetService.UpdateLineManagerRemarks(objectivesetid, remarks); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("saveTrainingNeedAnalysis")] public ActionResult saveTrainingNeedAnalysis(TrainingNeedAnalysis item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { if (item.IsNew) { item.CreatedBy = (int)currentUser.EmployeeID; item.CreatedDate = DateTime.Now; } else { item.ModifiedBy = currentUser.EmployeeID; item.ModifiedDate = DateTime.Now; } _trainingNeedAnalysisService.Save(item, currentUser); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("getTrainingNeedAnalysisByEmployeeObjectiveSet")] public ActionResult GetTrainingNeedAnalysisByEmployeeObjectiveSet(dynamic data) { List trainingNeedAnalyses = new List(); int employeeID = (int)data["employeeID"].ToObject(); int objectiveSetID = (int)data["objectiveSetID"].ToObject(); try { trainingNeedAnalyses = _trainingNeedAnalysisService.GetTrainingNeedAnalysisByEmployeeObjectiveSet(employeeID, objectiveSetID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(trainingNeedAnalyses); } [HttpGet("GetTrainingNeedAnalysisByEmployee")] public ActionResult GetTrainingNeedAnalysisByEmployee() { List trainingNeedAnalyses = new List(); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { trainingNeedAnalyses = _trainingNeedAnalysisService.GetTrainingNeedAnalysisByEmployee((int)currentUser.EmployeeID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(trainingNeedAnalyses); } [HttpGet("deleteTrainingNeedAnalysis/{id}")] public ActionResult DeleteTrainingNeedAnalysis(int id) { try { _trainingNeedAnalysisService.Delete(id); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("getTrainingNeedAnalysisHistoryByEmployee")] public ActionResult getTrainingNeedAnalysisHistoryByEmployee(dynamic data) { List trainingNeedAnalyses = new List(); int employeeID = (int)data["employeeID"].ToObject(); int activepmpYearId = (int)data["pmpYearId"].ToObject(); try { trainingNeedAnalyses = _trainingNeedAnalysisService.getTrainingNeedAnalysisHistoryByEmployee(employeeID, activepmpYearId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(trainingNeedAnalyses); } [HttpPost] [Route("submitDevelopmentPlan")] public ActionResult SubmitDevelopmentPlan(dynamic data) { int objectiveSetID = (int)data["objectiveSetID"].ToObject(); bool isEmployee = (bool)data["isEmployee"].ToObject(); enumIDPStatus status = (enumIDPStatus)data["idpEmployeeStatus"].ToObject(); string careerExpectation = (string)data["careerExpectations"].ToObject(); try { _objectiveSetService.SubmitDevelopmentPlan(objectiveSetID, isEmployee, status, careerExpectation); ObjectiveSet oObj = _objectiveSetService.Get(objectiveSetID); Employee oemp = _employeeService.Get(oObj.EmployeeID); Employee LineManager = oemp.LineManagerID != null && oemp.LineManagerID != 0 ? _employeeService.Get(oemp.LineManagerID.Value) : null; if (LineManager != null && LineManager.EmailAddress != "") { EmailSettings emailSettings = _emailSettings.Value; MailSender mailSender = new MailSender(); mailSender.AddTo(LineManager.EmailAddress); mailSender.Subject = "Development Waiting for Your Approval"; mailSender.Body = "Dear " + LineManager.Name + ",

" + oemp.Name + " has submitted a development plan which is waiting for your approval" + "

Thanks"; mailSender.ThreadSendMail(emailSettings); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("approveDevelopmentPlan")] public ActionResult approveDevelopmentPlan(dynamic data) { var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); int objectiveSetID = item["objectiveSetID"].ToObject(); CurrentUser oCurrentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { _objectiveSetService.approveDevelopmentPlan(objectiveSetID, (int)oCurrentUser.EmployeeID); ObjectiveSet os = _objectiveSetService.Get(objectiveSetID); Employee oemp = _employeeService.Get(os.EmployeeID); if (oemp.EmailAddress != "") { EmailSettings emailSettings = _emailSettings.Value; MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = "Your Development Plan is Approved"; mailSender.Body = "Dear " + oemp.Name + ",

Your Independent Development Plan has been Approved" + "

Thanks"; mailSender.ThreadSendMail(emailSettings); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("rejectDevelopmentPlan")] public ActionResult rejectDevelopmentPlan(dynamic data) { var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); int objectiveSetID = item["objectiveSetID"].ToObject(); CurrentUser oCurrentUser = CurrentUser.GetCurrentUser(HttpContext.User); try { _objectiveSetService.rejectDevelopmentPlan(objectiveSetID, (int)oCurrentUser.EmployeeID); ObjectiveSet os = _objectiveSetService.Get(objectiveSetID); Employee oemp = _employeeService.Get(os.EmployeeID); if (oemp.EmailAddress != "") { EmailSettings emailSettings = _emailSettings.Value; MailSender mailSender = new MailSender(); mailSender.AddTo(oemp.EmailAddress); mailSender.Subject = "Your Development Plan is Reverted"; mailSender.Body = "Dear " + oemp.Name + ",

Your Independent Development Plan has been reverted back to you. Please check and " + "submit again.

Thanks"; mailSender.ThreadSendMail(emailSettings); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("GetSearchIDPDashboard")] public ActionResult GetSearchIDPDashboard(dynamic data) { var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); int? pmpYearID = item["pmpYearID"] != null && !string.IsNullOrEmpty(item["pmpYearID"].ToString()) ? item["pmpYearID"].ToObject() : (int?)null; int? lmid = item["lmid"] != null && !string.IsNullOrEmpty(item["lmid"].ToString()) ? item["lmid"].ToObject() : (int?)null; int? secondLmid = item["secondLmid"] != null && !string.IsNullOrEmpty(item["secondLmid"].ToString()) ? item["secondLmid"].ToObject() : (int?)null; bool? isCompleted = item["isCompleted"] != null && !string.IsNullOrEmpty(item["isCompleted"].ToString()) ? item["isCompleted"].ToObject() : (bool?)null; bool? isNotYetCompleted = item["isNotYetCompleted"] != null && !string.IsNullOrEmpty(item["isNotYetCompleted"].ToString()) ? item["isNotYetCompleted"].ToObject() : (bool?)null; string type = item["type"] != null && !string.IsNullOrEmpty(item["type"].ToString()) ? item["type"].ToObject() : null; DataTable dt = new DataTable(); try { dt = _objectiveSetService.GetSearchIDPDashboard(pmpYearID, lmid, secondLmid, isCompleted, isNotYetCompleted, type); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(dt); } #endregion #region Objective history (outside-of-settings KPI changes) and KPI attachments [HttpPost] [Route("UpdateObjectiveHistorySubmitStatus/{isSubmitted}")] public ActionResult UpdateObjectiveHistorySubmitStatus(bool isSubmitted, ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); int employeeId = currentUser.EmployeeID.GetValueOrDefault(); int payrollTypeId = currentUser.PayrollTypeID.GetValueOrDefault(); item.EmployeeID = employeeId; item.PayrollTypeID = payrollTypeId; item.ModifiedBy = currentUser.UserID; try { this._objectiveService.UpdateObjectiveHistorySubmitStatus(item, isSubmitted); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getUpdatedObjectives/{objectiveSetId}")] public ActionResult getUpdatedObjectives(int objectiveSetId) { DataTable items = null; try { items = _objectiveService.GetObjectiveFromHistoryDT(objectiveSetId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpPost] [Route("RejectObjectiveHistory")] public ActionResult RejectObjectiveHistory(ObjectiveSet item) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); item.ModifiedBy = currentUser.UserID; try { this._objectiveService.RejectObjectiveHistory(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("getObjectiveHistoryStatus/{objectiveSetId}")] public ActionResult getObjectiveHistoryStatus(int objectiveSetId) { DataTable items = null; try { items = _objectiveService.GetObjectiveHistoryStatus(objectiveSetId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpGet] [Route("getObjectiveHistoryWeightage/{objectiveSetId}")] public ActionResult getObjectiveHistoryWeightage(int objectiveSetId) { DataTable items = null; try { items = _objectiveService.GetObjectiveHistoryWeightage(objectiveSetId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(items); } [HttpPost] [Route("dismissObjectiveHistory/{objectiveHistoryId}")] public ActionResult dismissObjectiveHistory(int objectiveHistoryId) { try { this._objectiveService.DismissObjectiveHistory(objectiveHistoryId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpGet] [Route("GetObjectiveAttachmentFileData/{attachmentid}")] public ActionResult GetObjectiveAttachmentFileData(int attachmentid) { ObjectiveAttachment data; try { data = _objectiveService.GetObjectiveAttachmentFileData(attachmentid); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(data); } [HttpGet] [Route("GetObjectiveAttachmentsByHistoryID/{objectiveHistoryId}")] public ActionResult GetObjectiveAttachmentsByHistoryID(int objectiveHistoryId) { List data; try { data = _objectiveService.GetObjectiveAttachmentsByHistoryID(objectiveHistoryId); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(data); } [HttpPost] [Route("DeleteobjectiveAttachment")] public ActionResult DeleteobjectiveAttachment(ObjectiveAttachment item) { try { _objectiveService.DeleteObjectiveAttachmentByID(item.ID); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(); } [HttpPost] [Route("InsertObjectiveAttachment")] public ActionResult InsertObjectiveAttachment(ObjectiveAttachment item) { int id; try { id = _objectiveService.InsertObjectiveAttachment(item); } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(id); } #endregion } }