using HRM.BO; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.Data; using System; using HRM.Report; using Ease.Core.DataAccess; using Microsoft.Reporting.NETCore; using Microsoft.Extensions.Options; using HRM.BO.Configuration; namespace HRM.UI.Controllers.Ess_Fund { [Route("api/EssFund")] [ApiController] public class EssFundController : ControllerBase { private readonly IMemberService _memberService; private readonly IMembersTransactionDetailsService _membersTransactionDetailsService; private readonly IOptions _fundInfo; public EssFundController(IMemberService memberService, IMembersTransactionDetailsService membersTransactionDetailsService, IOptions fundInfo) { _memberService = memberService; _membersTransactionDetailsService = membersTransactionDetailsService; _fundInfo = fundInfo; } #region Commented Out Fund-related Codes //[HttpGet("getPFDepositFlow/{ID}")] //public ActionResult getPFDepositFlow(int id) //{ // PFDepositFlow item = new PFDepositFlow(); // try // { // item = _pFDepositFlowService.Get(id); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(item); //} //[HttpGet("getLoanApplication")] //public ActionResult getLoanApplication() //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // LoanApplication item = new LoanApplication(); // try // { // item = _loanApplicationService.Get(currentUser.MemberID); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(item); //} //// Salary Monthly //[HttpGet("getSalaryMonthlyByEmpId")] //public ActionResult GetSalaryMonthlyByEmpId() //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // double empBasicSalary = 0.0; // try // { // empBasicSalary = _employeeService.GetEmpBasicSalary((int)currentUser.EmployeeID); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(empBasicSalary); //} //[HttpGet("getLoanAppById/{LoanAppId}")] //public ActionResult GetLoanAppById(int LoanAppId) //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // LoanApplication item = new LoanApplication(); // try // { // item = _loanApplicationService.GetLoanAppById(LoanAppId); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(item); //} //[HttpGet("getLoansById/{LoanID}")] //public ActionResult GetLoanById(int LoanID) //{ // List loans = new List(); // try // { // loans = _fmLoanService.Get(LoanID, true); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(loans); //} //[HttpGet("getLoanAppEligibility")] //public ActionResult GetLoanAppEligibility() //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // int unpaidPayDateCount = 0; // try // { // unpaidPayDateCount = _fmLoanService.GetLoanAppEligibility(currentUser.MemberID); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(unpaidPayDateCount); //} //[HttpGet("getScheduleByLoanID/{LoanID}")] //public ActionResult GetScheduleByLoanID(int LoanID) //{ // DataTable oLoanScheduleDataTable = new DataTable(); // try // { // oLoanScheduleDataTable = _loanApplicationService.GetLoanScheduleByLoanID(LoanID); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(oLoanScheduleDataTable); //} //[HttpGet("getLoanApps")] //public ActionResult GetLoanApps() //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // //Member LoanHr = _memberService.Get(_fundEss.Value.LoanHrUser); // //Member Trustee = _memberService.Get(_fundEss.Value.LoanTrustee); // //Member SecondTrustee = _memberService.Get(_fundEss.Value.LoanSecondTrustee); // DataTable oLoanAppsDataTable = new DataTable(); // DataTable oLoanScheduleDataTable = new DataTable(); // try // { // oLoanAppsDataTable = _loanApplicationService.GetLoanApps(currentUser.MemberID); // oLoanAppsDataTable.Columns.Add("SettleStatusString", typeof(string)); // oLoanAppsDataTable.Columns.Add("loanApplicationCount", typeof(int)); // oLoanAppsDataTable.Columns.Add("DepositStatus", typeof(string)); // int pendingLoanCount = 0; // foreach (DataRow row in oLoanAppsDataTable.Rows) // { // row["loanStatus"] = (row["loanStatus"].ToString() == "loanapp") ? "On Approval" : "Approved and Issued"; // //For LoanApplication table, type=1; for Loan table, type=2 // if ((Int64)row["loanType"] == 2) // { // oLoanScheduleDataTable = _loanApplicationService.GetLoanScheduleByLoanID((int)row["loanAppID"]); // int unpaidPayDateCount = 0; // foreach (DataRow dr in oLoanScheduleDataTable.Rows) // { // if (dr["PayDate"] == DBNull.Value) //.ToString() == string.Empty // { // unpaidPayDateCount++; // } // } // row["loanStatus"] = (unpaidPayDateCount > 0) ? "Approved and Deposited" : "Loan Fully Paid"; // row["DepositStatus"] = "Yes"; // var x = row["loanStatus"].ToString(); // if (row["SettleStatus"] != DBNull.Value && row["SettleStatus"] != null) // { // //EnumLoanSettleStatus settleStatus = (EnumLoanSettleStatus)(short)row["SettleStatus"]; // row["SettleStatusString"] = Enum.GetName(typeof(EnumLoanSettleStatus), ((EnumLoanSettleStatus?)(short)row["SettleStatus"]).Value); // } // else // { // row["SettleStatusString"] = Enum.GetName(typeof(EnumLoanSettleStatus), EnumLoanSettleStatus.None); // } // } // else // { // row["settleStatus"] = 0; // row["SettleStatusString"] = Enum.GetName(typeof(EnumLoanSettleStatus), EnumLoanSettleStatus.None); // if (row["isRejected"] != DBNull.Value && (Int16)row["isRejected"] != 0) // { // if (row["isHrApproved"] != DBNull.Value && row["isApproved"] != DBNull.Value && row["isSecondApproved"] != DBNull.Value) // { // row["loanStatus"] = "Rejected (Trustee-2)"; // row["DepositStatus"] = "No"; // } // else if (row["isHrApproved"] != DBNull.Value && row["isApproved"] != DBNull.Value && row["isSecondApproved"] == DBNull.Value) // { // row["loanStatus"] = "Rejected (Trustee-1) "; // row["DepositStatus"] = "No"; // } // else if (row["isHrApproved"] != DBNull.Value && row["isApproved"] == DBNull.Value && row["isSecondApproved"] != DBNull.Value) // { // row["loanStatus"] = "Rejected (Trustee-1)"; // row["DepositStatus"] = "No"; // } // else if (row["isHrApproved"] != DBNull.Value && row["isApproved"] == DBNull.Value && row["isSecondApproved"] == DBNull.Value) // { // row["loanStatus"] = "Rejected (HR Admin) "; // row["DepositStatus"] = "No"; // } // } // else // { // if (row["isHrApproved"] == DBNull.Value // && row["isApproved"] == DBNull.Value // && row["isSecondApproved"] == DBNull.Value) // { // row["loanStatus"] = "On Approval (HR)"; // row["DepositStatus"] = "No"; // } // else if (row["isHrApproved"] != DBNull.Value && row["isApproved"] == DBNull.Value && row["isSecondApproved"] == DBNull.Value) // { // row["loanStatus"] = "On Approval (Trustee-1)"; // row["DepositStatus"] = "No"; // } // else if ((row["isHrApproved"] != DBNull.Value && row["isApproved"] != DBNull.Value && row["isSecondApproved"] == DBNull.Value) || // (row["isHrApproved"] != DBNull.Value && row["isApproved"] == DBNull.Value && row["isSecondApproved"] != DBNull.Value)) // { // row["loanStatus"] = "On Approval (Trustee-2)"; // row["DepositStatus"] = "No"; // } // else if (row["isHrApproved"] != DBNull.Value && row["isApproved"] != DBNull.Value // && row["isSecondApproved"] != DBNull.Value && row["isDeposited"] == DBNull.Value) // { // row["loanStatus"] = "All Approved (Bank transaction pending)"; // row["DepositStatus"] = "No"; // } // else if (row["isHrApproved"] != DBNull.Value && row["isApproved"] != DBNull.Value // && row["isSecondApproved"] != DBNull.Value && row["isDeposited"] != DBNull.Value) // { // row["DepositStatus"] = "Yes"; // if (Convert.ToDateTime(row["isDeposited"]).Day >= 11 && Convert.ToDateTime(row["isDeposited"]).Day <= 15) // { // row["loanStatus"] = "Bank transaction between 11th-15th"; // } // else if (Convert.ToDateTime(row["isDeposited"]).Day >= 25 && Convert.ToDateTime(row["isDeposited"]).Day <= 30) // { // row["loanStatus"] = "Bank transaction between 25th-30th"; // } // } // pendingLoanCount++; // } // } // row["loanApplicationCount"] = pendingLoanCount; //Used for enabling or disabling Loan Apply button by checking, if any Loan application is pending // } // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(oLoanAppsDataTable); //} //[HttpGet("getPFWithdrawalGrid/{memberId}")] //public ActionResult GetPFWithdrawalGrid(int memberId) //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // Member omember = new Member(); // if (memberId == -1) // { // omember = _memberService.Get(currentUser.MemberID); // } // else // { // omember = _memberService.Get(memberId); // } // //DateTime memDate = (DateTime)omember.MembershipDate; // TimeSpan timeDifference = DateTime.Now - omember.DOJ; // int membershipDuration = (int)timeDifference.TotalDays; // List staticDescriptions = new List{"A. Audited Closing Balance", // "B. Contribution During the Year", // "C. PF Loan Outstanding Balance", // "D. Total Amount", // "E. Transfer to Lapses & forfeiture A/C", // "F. Net Amount Payable"}; // double[] epfContributionArr = new double[6]; // double[] cpfContributionArr = new double[6]; // double[] total = new double[6]; // DataRow odrInfo = null; // DataTable oPFWithdrawalGrid = new DataTable(); // oPFWithdrawalGrid.Columns.Add("Description", typeof(string)); // oPFWithdrawalGrid.Columns.Add("epfContribution", typeof(string)); // oPFWithdrawalGrid.Columns.Add("cpfContribution", typeof(string)); // oPFWithdrawalGrid.Columns.Add("total", typeof(string)); // oPFWithdrawalGrid.Columns.Add("IsRequestPending", typeof(bool)); // try // { // PFWithdrawalRequest pFWithdrawalRequest = new PFWithdrawalRequest(); // int pendingRequestCount = 0; // pFWithdrawalRequest = _pfWithdrawalRequestService.GetByMemberID(omember.ID); // pendingRequestCount = _pfWithdrawalRequestService.PFWithdrawalRequestCount(omember.ID); // epfContributionArr[0] = _membersTransactionDetailsService.GetDashboardMemberAuditedOwnBalance(omember.ID); // cpfContributionArr[0] = _membersTransactionDetailsService.GetDashboardMemberAuditedOwnBalance(omember.ID); // total[0] = epfContributionArr[0] + cpfContributionArr[0]; // epfContributionArr[1] = _membersTransactionDetailsService.GetDashboardMemberUnAuditedOwnBalance(omember.ID); // cpfContributionArr[1] = _membersTransactionDetailsService.GetDashboardMemberUnAuditedCompanyBalance(omember.ID); // total[1] = epfContributionArr[1] + cpfContributionArr[1]; // total[2] = _fmLoanService.GetLoanOustandingAmount(omember.ID); // for (int i = 0; i < 6; i++) // { // odrInfo = oPFWithdrawalGrid.NewRow(); // odrInfo["Description"] = staticDescriptions[i]; // if (i <= 1) // { // odrInfo["epfContribution"] = epfContributionArr[i].ToString("N2"); // odrInfo["cpfContribution"] = cpfContributionArr[i].ToString("N2"); // odrInfo["total"] = total[i].ToString("N2"); // if (pFWithdrawalRequest != null) // { // odrInfo["IsRequestPending"] = (pendingRequestCount > 0 || pFWithdrawalRequest.Status != EnumPFWithdrawalStatus.Confirmed) ? true : false; // } // } // else // { // odrInfo["epfContribution"] = " "; // odrInfo["cpfContribution"] = " "; // switch (i) // { // case 2: // odrInfo["total"] = total[2].ToString("N2"); // break; // case 3: // total[3] = total[0] + total[1] - total[2]; // odrInfo["total"] = total[3].ToString("N2"); // break; // case 4: // total[4] = (membershipDuration < 365 * 2) ? cpfContributionArr[0] + cpfContributionArr[1] : 0; // odrInfo["total"] = total[4].ToString("N2"); // break; // default: // odrInfo["total"] = (total[3] - total[4]).ToString("N2"); // break; // } // } // oPFWithdrawalGrid.Rows.Add(odrInfo); // } // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(oPFWithdrawalGrid); //} //[HttpGet("getPFMemberWithdrawalFlowGridData/{requestMemberID}")] //public ActionResult getPFMemberWithdrawalFlowGridData(int requestMemberID) //{ // PFWithdrawalRequest pFWithdrawalRequest = new PFWithdrawalRequest(); // pFWithdrawalRequest = _pfWithdrawalRequestService.GetByMemberID(requestMemberID); // //Member LoanHr = _memberService.Get(_fundEss.Value.LoanHrUser); // //Member Trustee = _memberService.Get(_fundEss.Value.LoanTrustee); // //Member SecondTrustee = _memberService.Get(_fundEss.Value.LoanSecondTrustee); // List staticDescriptions = new List{"Withdraw Date", // "Deduction Stop", // "Admin Acknowledgement", // "Trustee-1 Approval", // "Trustee-2 Approval", // "Bank Deposit"}; // DataRow odrInfo = null; // DataTable oPFWithdrawalFlowGrid = new DataTable(); // oPFWithdrawalFlowGrid.Columns.Add("description", typeof(string)); // oPFWithdrawalFlowGrid.Columns.Add("status", typeof(string)); // oPFWithdrawalFlowGrid.Columns.Add("acknowledgementDate", typeof(string)); // try // { // for (int i = 0; i < 6; i++) // { // odrInfo = oPFWithdrawalFlowGrid.NewRow(); // odrInfo["Description"] = staticDescriptions[i]; // switch (i) // { // case 0: // odrInfo["status"] = "-"; // odrInfo["acknowledgementDate"] = pFWithdrawalRequest.DiscontinueDate.ToString(); // break; // case 1: // odrInfo["status"] = "-"; // odrInfo["acknowledgementDate"] = pFWithdrawalRequest.DiscontinueDate.ToString(); // break; // case 2: // //odrInfo["status"] = (pFWithdrawalRequest.HRApproveDate != null && pFWithdrawalRequest.isRejected != true) ? "Yes" : "No"; // if (pFWithdrawalRequest.HRApproveDate != null && pFWithdrawalRequest.isRejected != true) // { // odrInfo["status"] = "Yes"; // } // else if (pFWithdrawalRequest.HRApproveDate != null && pFWithdrawalRequest.isRejected == true && // (pFWithdrawalRequest.TrusteesApproveDate != null || pFWithdrawalRequest.SecondTrusteesApproveDate != null)) // { // odrInfo["status"] = "Yes"; // } // else if (pFWithdrawalRequest.HRApproveDate != null && pFWithdrawalRequest.TrusteesApproveDate == null && // pFWithdrawalRequest.SecondTrusteesApproveDate == null && pFWithdrawalRequest.isRejected == true) // { // odrInfo["status"] = "Rejected"; // } // else // { // odrInfo["status"] = "No"; // } // odrInfo["acknowledgementDate"] = pFWithdrawalRequest.HRApproveDate.ToString(); // break; // case 3: // //odrInfo["status"] = (pFWithdrawalRequest.TrusteesApproveDate != null && pFWithdrawalRequest.isRejected != true) ? "Yes" : "No"; // if (pFWithdrawalRequest.TrusteesApproveDate != null && pFWithdrawalRequest.isRejected != true) // { // odrInfo["status"] = "Yes"; // } // else if (pFWithdrawalRequest.TrusteesApproveDate != null && pFWithdrawalRequest.HRApproveDate != null && // pFWithdrawalRequest.SecondTrusteesApproveDate == null && pFWithdrawalRequest.isRejected == true) // { // odrInfo["status"] = "Rejected"; // } // else // { // odrInfo["status"] = "No"; // } // odrInfo["acknowledgementDate"] = pFWithdrawalRequest.TrusteesApproveDate.ToString(); // break; // case 4: // //odrInfo["status"] = (pFWithdrawalRequest.SecondTrusteesApproveDate != null && pFWithdrawalRequest.isRejected != true) ? "Yes" : "No"; // if (pFWithdrawalRequest.SecondTrusteesApproveDate != null && pFWithdrawalRequest.isRejected != true) // { // odrInfo["status"] = "Yes"; // } // else if (pFWithdrawalRequest.SecondTrusteesApproveDate != null && pFWithdrawalRequest.HRApproveDate != null && // pFWithdrawalRequest.TrusteesApproveDate == null && pFWithdrawalRequest.isRejected == true) // { // odrInfo["status"] = "Rejected"; // } // else // { // odrInfo["status"] = "No"; // } // odrInfo["acknowledgementDate"] = pFWithdrawalRequest.SecondTrusteesApproveDate.ToString(); // break; // case 5: // odrInfo["status"] = (pFWithdrawalRequest.DepositDate != null) ? "Yes" : "No"; // odrInfo["acknowledgementDate"] = pFWithdrawalRequest.DepositDate.ToString(); ; // break; // default: // odrInfo["status"] = "Rejected"; // break; // } // oPFWithdrawalFlowGrid.Rows.Add(odrInfo); // } // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(oPFWithdrawalFlowGrid); //} //[HttpGet("getNewInvestment")] //public ActionResult GetNewInvestment() //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // NewInvestment oNewInvestment = new NewInvestment(); // try // { // oNewInvestment = _newInvestmentService.GetByMemberID(currentUser.MemberID); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(oNewInvestment); //} //[HttpGet("getNewInvestmentById/{NewInvestmentId}")] //public ActionResult GetNewInvestmentById(int NewInvestmentId) //{ // NewInvestment item = new NewInvestment(); // try // { // item = _newInvestmentService.GetNewInvestmentById(NewInvestmentId); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(item); //} //[HttpPost] //[Route("saveLoanApplication")] //public ActionResult saveLoanApplication(LoanApplication loanApplication) //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // loanApplication.ConnectionString = Ease.Core.Utility.Global.CipherFunctions.Decrypt("Cel.Admin", _fundEss.Value.MySqlCommandConnection); // //loanApplication.ConnectionString = _fundEss.Value.MySqlCommandConnection; /*"server=103.197.204.164;user=root;database=bl;port=3306;password=MySql1234";*/ // try // { // if (loanApplication.LoanAttachments != null && loanApplication.LoanAttachments.Count > 0) // { // foreach (var tempItem in loanApplication.LoanAttachments) // { // if (tempItem != null) // { // if (tempItem.ID <= 0 && tempItem.FileDataString != null) // { // string[] items = tempItem.FileDataString.Split(new char[] { ',', ' ' }, StringSplitOptions.None); // byte[] newBytes = Convert.FromBase64String(items[1]); // tempItem.FileDataString = ""; // tempItem.FileData = newBytes; // } // } // } // } // Member LoanHr = _memberService.Get(_fundEss.Value.LoanHrUser); // Member Trustee = _memberService.Get(_fundEss.Value.LoanTrustee); // Member SecondTrustee = _memberService.Get(_fundEss.Value.LoanSecondTrustee); // loanApplication.ApplyDate = DateTime.Now; // loanApplication.HRUserID = LoanHr.ID; // loanApplication.TrusteesID = Trustee.ID; // loanApplication.SecondTrusteesID = SecondTrustee.ID; // loanApplication.MemberID = currentUser.MemberID; // loanApplication.CreatedDate = DateTime.Today; // _loanApplicationService.Save(loanApplication); // EmailSettings emailSettings = _emailSettings.Value; // //send mail to hr // string temperr = _loanApplicationService.SendMailToTheApprovedLoanHR(loanApplication, emailSettings); // //send mail to applicant // temperr = _loanApplicationService.SendMailToTheApplicant(loanApplication, emailSettings); // //if (temperr != string.Empty) // //{ // // throw new Exception(temperr); // //} // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(loanApplication); //} //[HttpPost] //[Route("confirmPFWithdrawalRequestTerms")] //public ActionResult ConfirmPFWithdrawalRequestTerms(PFWithdrawalRequest pFWithdrawalRequest) //{ // try // { // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // Member Hr = _memberService.Get(_fundEss.Value.LoanHrUser); // pFWithdrawalRequest.Status = EnumPFWithdrawalStatus.Confirmed; // pFWithdrawalRequest.RequestEmployeeID = (int)currentUser.EmployeeID; // pFWithdrawalRequest.RequestMemberID = currentUser.MemberID; // pFWithdrawalRequest.ConfirmDate = DateTime.Today; // pFWithdrawalRequest.CreatedBy = (int)currentUser.EmployeeID; // pFWithdrawalRequest.CreatedDate = DateTime.Today; // _pfWithdrawalRequestService.Save(pFWithdrawalRequest); // //EmailSettings emailSettings = _emailSettings.Value; // //string temperr = _pfWithdrawalRequestService.SendMailToPfMembershipWithdrawalHR(pFWithdrawalRequest, emailSettings, Hr.ID); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(pFWithdrawalRequest); //} //[HttpPost] //[Route("savePFWithdrawalRequest")] //public ActionResult SavePFWithdrawalRequest(PFWithdrawalRequest pFWithdrawalRequest) //{ // try // { // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // Member Hr = _memberService.Get(_fundEss.Value.LoanHrUser); // pFWithdrawalRequest.ConnectionString = Ease.Core.Utility.Global.CipherFunctions.Decrypt("Cel.Admin", _fundEss.Value.MySqlCommandConnection); // pFWithdrawalRequest.RequestEmployeeID = (int)currentUser.EmployeeID; // pFWithdrawalRequest.RequestMemberID = currentUser.MemberID; // pFWithdrawalRequest.RequestDate = DateTime.Today; // pFWithdrawalRequest.Status = EnumPFWithdrawalStatus.Submitted; // pFWithdrawalRequest.StatusUpdateDate = DateTime.Today; // pFWithdrawalRequest.CreatedBy = (int)currentUser.EmployeeID; // pFWithdrawalRequest.CreatedDate = DateTime.Today; // if (pFWithdrawalRequest.PfWithdrawalRequestAttachment != null && pFWithdrawalRequest.isRejected != true) // { // if (pFWithdrawalRequest.PfWithdrawalRequestAttachment.FileDataString != null) // { // string[] items = pFWithdrawalRequest.PfWithdrawalRequestAttachment.FileDataString.Split(new char[] { ',', ' ' }, StringSplitOptions.None); // byte[] newBytes = Convert.FromBase64String(items[1]); // pFWithdrawalRequest.PfWithdrawalRequestAttachment.FileDataString = ""; // pFWithdrawalRequest.PfWithdrawalRequestAttachment.FileData = newBytes; // } // } // _pfWithdrawalRequestService.Save(pFWithdrawalRequest); // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _pfWithdrawalRequestService.SendMailToPfMembershipWithdrawalHR(pFWithdrawalRequest, emailSettings, Hr.ID); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(pFWithdrawalRequest); //} //[HttpPost] //[Route("updatePfDepositFlowApproved")] //public ActionResult UpdatePfDepositFlowApproved(PFDepositFlow oPFDepositFlow) //{ // try // { // Member Hr = _memberService.Get(_fundEss.Value.LoanHrUser); // oPFDepositFlow.ApprovedDate = DateTime.Now; // _pFDepositFlowService.UpdateApproved(oPFDepositFlow); // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _pFDepositFlowService.SendMailToHr(emailSettings, Hr.ID); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(oPFDepositFlow); //} //[HttpPost] //[Route("updateLoanApproveByHr")] //public ActionResult UpdateLoanApproveByHr(LoanApplication oLoanApplication) //{ // try // { // oLoanApplication.HRApproveDate = DateAndTime.Now; // _loanApplicationService.UpdateLoanApproveByHr(oLoanApplication); // if (oLoanApplication.isRejected == false) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _loanApplicationService.SendMailToTrustees(oLoanApplication, emailSettings); // } // else // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _loanApplicationService.SendMailToTheRejectedLoanApplicant(oLoanApplication, emailSettings); // } // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(oLoanApplication); //} //[HttpPost] //[Route("updateLoanApproveByTrustees")] //public ActionResult UpdateLoanApproveByTrustees(LoanApplication oLoanApplication) //{ // try // { // oLoanApplication.TrusteesApproveDate = DateAndTime.Now; // _loanApplicationService.UpdateLoanApproveByTrustees(oLoanApplication); // //mail // if (oLoanApplication.TrusteesApproveDate != null && oLoanApplication.SecondTrusteesApproveDate != null && oLoanApplication.isRejected == false) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _loanApplicationService.SendMailToTheApprovedLoanApplicant(oLoanApplication, emailSettings); // } // else if (oLoanApplication.TrusteesApproveDate != null && oLoanApplication.isRejected == true) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _loanApplicationService.SendRejectionMailOfEmployeeToSecondTrustee(oLoanApplication, emailSettings); // emailSettings = _emailSettings.Value; // temperr = _loanApplicationService.SendMailToTheRejectedLoanApplicant(oLoanApplication, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new LoanApplicationService().SendMailOfTheRejectedLoanApplicantBySecondTrusteeToHR(oLoanApplication, emailSettings); // } // else if (oLoanApplication.SecondTrusteesApproveDate != null && oLoanApplication.isRejected == true) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _loanApplicationService.SendRejectionMailOfEmployeeToTrustee(oLoanApplication, emailSettings); // emailSettings = _emailSettings.Value; // temperr = _loanApplicationService.SendMailToTheRejectedLoanApplicant(oLoanApplication, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new LoanApplicationService().SendMailOfTheRejectedLoanApplicantByFirstTrusteeToHR(oLoanApplication, emailSettings); // } // return Ok(oLoanApplication); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } //} //[HttpPost] //[Route("updateLoanApproveBySecondTrustees")] //public ActionResult UpdateLoanApproveBySecondTrustees(LoanApplication oLoanApplication) //{ // try // { // oLoanApplication.SecondTrusteesApproveDate = DateTime.Now; // _loanApplicationService.UpdateLoanApproveBySecondTrustees(oLoanApplication); // //mail // if (oLoanApplication.TrusteesApproveDate != null && oLoanApplication.SecondTrusteesApproveDate != null && oLoanApplication.isRejected == false) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _loanApplicationService.SendMailToTheApprovedLoanApplicant(oLoanApplication, emailSettings); // } // else if (oLoanApplication.TrusteesApproveDate != null && oLoanApplication.isRejected == true) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _loanApplicationService.SendRejectionMailOfEmployeeToSecondTrustee(oLoanApplication, emailSettings); // emailSettings = _emailSettings.Value; // temperr = _loanApplicationService.SendMailToTheRejectedLoanApplicant(oLoanApplication, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new LoanApplicationService().SendMailOfTheRejectedLoanApplicantBySecondTrusteeToHR(oLoanApplication, emailSettings); // } // else if (oLoanApplication.SecondTrusteesApproveDate != null && oLoanApplication.isRejected == true) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _loanApplicationService.SendRejectionMailOfEmployeeToTrustee(oLoanApplication, emailSettings); // emailSettings = _emailSettings.Value; // temperr = _loanApplicationService.SendMailToTheRejectedLoanApplicant(oLoanApplication, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new LoanApplicationService().SendMailOfTheRejectedLoanApplicantByFirstTrusteeToHR(oLoanApplication, emailSettings); // } // return Ok(oLoanApplication); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } //} //[HttpPost] //[Route("updatePfMembershipWithdrawalApproveByTrustees")] //public ActionResult UpdatePfMembershipWithdrawalApproveByTrustees(PFWithdrawalRequest oPFWithdrawalRequest) //{ // try // { // oPFWithdrawalRequest.TrusteesApproveDate = DateAndTime.Now; // if (oPFWithdrawalRequest.TrusteesApproveDate != null && oPFWithdrawalRequest.SecondTrusteesApproveDate != null && oPFWithdrawalRequest.isRejected == false) // { // oPFWithdrawalRequest.Status = EnumPFWithdrawalStatus.Approved; // } // if (oPFWithdrawalRequest.isRejected == true) // { // oPFWithdrawalRequest.Status = EnumPFWithdrawalStatus.Rejected; // } // Member Hr = _memberService.Get(_fundEss.Value.LoanHrUser); // //mail // if (oPFWithdrawalRequest.TrusteesApproveDate != null && oPFWithdrawalRequest.SecondTrusteesApproveDate != null && oPFWithdrawalRequest.isRejected == false) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _pfWithdrawalRequestService.SendMailToPfMembershipWithdrawalApplicant(oPFWithdrawalRequest, emailSettings); // } // else if (oPFWithdrawalRequest.TrusteesApproveDate != null && oPFWithdrawalRequest.isRejected == true) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = new PFWithdrawalRequestService().SendRejectionMailOfEmployeeToSecondTrustee(oPFWithdrawalRequest, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new PFWithdrawalRequestService().SendMailToTheRejectedPFWithdrawalRequestApplicant(oPFWithdrawalRequest, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new PFWithdrawalRequestService().SendMailOfTheRejectedPFWithdrawalBySecondTrusteeToHR(oPFWithdrawalRequest, Hr.EmpCode, emailSettings); // } // else if (oPFWithdrawalRequest.SecondTrusteesApproveDate != null && oPFWithdrawalRequest.isRejected == true) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = new PFWithdrawalRequestService().SendRejectionMailOfEmployeeToTrustee(oPFWithdrawalRequest, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new PFWithdrawalRequestService().SendMailToTheRejectedPFWithdrawalRequestApplicant(oPFWithdrawalRequest, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new PFWithdrawalRequestService().SendMailOfTheRejectedPFWithdrawalBySecondTrusteeToHR(oPFWithdrawalRequest, Hr.EmpCode, emailSettings); // } // _pfWithdrawalRequestService.UpdatePfMembershipWithdrawalApproveByTrustees(oPFWithdrawalRequest); // return Ok(oPFWithdrawalRequest); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } //} //[HttpPost] //[Route("updatePfMembershipWithdrawalApproveBySecondTrustees")] //public ActionResult UpdatePfMembershipWithdrawalApproveBySecondTrustees(PFWithdrawalRequest oPFWithdrawalRequest) //{ // try // { // oPFWithdrawalRequest.SecondTrusteesApproveDate = DateTime.Now; // if (oPFWithdrawalRequest.TrusteesApproveDate != null && oPFWithdrawalRequest.SecondTrusteesApproveDate != null && oPFWithdrawalRequest.isRejected == false) // { // oPFWithdrawalRequest.Status = EnumPFWithdrawalStatus.Approved; // } // else if (oPFWithdrawalRequest.isRejected == true) // { // oPFWithdrawalRequest.Status = EnumPFWithdrawalStatus.Rejected; // } // _pfWithdrawalRequestService.UpdatePfMembershipWithdrawalApproveBySecondTrustees(oPFWithdrawalRequest); // Member Hr = _memberService.Get(_fundEss.Value.LoanHrUser); // //mail // if (oPFWithdrawalRequest.TrusteesApproveDate != null && oPFWithdrawalRequest.SecondTrusteesApproveDate != null) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _pfWithdrawalRequestService.SendMailToPfMembershipWithdrawalApplicant(oPFWithdrawalRequest, emailSettings); // } // else if (oPFWithdrawalRequest.TrusteesApproveDate != null && oPFWithdrawalRequest.isRejected == true) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = new PFWithdrawalRequestService().SendRejectionMailOfEmployeeToSecondTrustee(oPFWithdrawalRequest, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new PFWithdrawalRequestService().SendMailToTheRejectedPFWithdrawalRequestApplicant(oPFWithdrawalRequest, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new PFWithdrawalRequestService().SendMailOfTheRejectedPFWithdrawalByFirstTrusteeToHR(oPFWithdrawalRequest, Hr.EmpCode, emailSettings); // } // else if (oPFWithdrawalRequest.SecondTrusteesApproveDate != null && oPFWithdrawalRequest.isRejected == true) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = new PFWithdrawalRequestService().SendRejectionMailOfEmployeeToTrustee(oPFWithdrawalRequest, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new PFWithdrawalRequestService().SendMailToTheRejectedPFWithdrawalRequestApplicant(oPFWithdrawalRequest, emailSettings); // emailSettings = _emailSettings.Value; // temperr = new PFWithdrawalRequestService().SendMailOfTheRejectedPFWithdrawalByFirstTrusteeToHR(oPFWithdrawalRequest, Hr.EmpCode, emailSettings); // } // return Ok(oPFWithdrawalRequest); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } //} //[Route("getMemberLastAuditDate")] //public ActionResult GetMemberLastAuditDate() //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // DateTime? lastAuditDate = null; // //string AuditDate = string.Empty; // try // { // lastAuditDate = _membersTransactionDetailsService.GetMemberLastAuditDate(currentUser.MemberID); // //AuditDate = (lastAuditDate != null)? lastAuditDate.ToString() : "NoAudit"; // return Ok(lastAuditDate); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } //} //[HttpGet] //[Route("getDashboardData/{memberId}")] //public ActionResult GetDashboardData(int memberId) //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // Member omember = new Member(); // PFWithdrawalRequest pFWithdrawalRequest = new PFWithdrawalRequest(); // if (memberId == -1) // { // omember = _memberService.Get(currentUser.MemberID); // pFWithdrawalRequest = _pfWithdrawalRequestService.GetByMemberID(currentUser.MemberID); // } // else // { // omember = _memberService.Get(memberId); // pFWithdrawalRequest = _pfWithdrawalRequestService.GetByMemberID(currentUser.MemberID); // } // DataRow odrInfo = null; // DataTable oDashboardData = new DataTable(); // oDashboardData.Columns.Add("EmpCode", typeof(string)); // oDashboardData.Columns.Add("Designation", typeof(string)); // oDashboardData.Columns.Add("Department", typeof(string)); // oDashboardData.Columns.Add("JoiningDate", typeof(string)); // oDashboardData.Columns.Add("WithdrawalDate", typeof(string)); // oDashboardData.Columns.Add("WithdrawalStatus", typeof(EnumPFWithdrawalStatus)); // oDashboardData.Columns.Add("MembershipDate", typeof(string)); // oDashboardData.Columns.Add("EMAILADDRESS", typeof(string)); // oDashboardData.Columns.Add("Name", typeof(string)); // oDashboardData.Columns.Add("DiscontinueDate", typeof(string)); // oDashboardData.Columns.Add("MOBILENO", typeof(string)); // oDashboardData.Columns.Add("AuditedOwnBalance", typeof(double)).DefaultValue = 0.0; // oDashboardData.Columns.Add("AuditedCompanyBalance", typeof(double)).DefaultValue = 0.0; // oDashboardData.Columns.Add("UnAuditedOwnBalance", typeof(double)).DefaultValue = 0.0; // oDashboardData.Columns.Add("UnAuditedCompanyBalance", typeof(double)).DefaultValue = 0.0; // oDashboardData.Columns.Add("Conn", typeof(string)); // try // { // DataTable oDashboardMember = new DataTable(); // oDashboardMember = _memberService.GetDashboardMember(omember.EmpCode); // double auditedOwnBalance = 0, auditedCompanyBalance = 0, unAuditedOwnBalance = 0, unAuditedCompanyBalance = 0; // auditedOwnBalance = _membersTransactionDetailsService.GetDashboardMemberAuditedOwnBalance(omember.ID); // auditedCompanyBalance = _membersTransactionDetailsService.GetDashboardMemberAuditedCompanyBalance(omember.ID); // unAuditedOwnBalance = _membersTransactionDetailsService.GetDashboardMemberUnAuditedOwnBalance(omember.ID); // unAuditedCompanyBalance = _membersTransactionDetailsService.GetDashboardMemberUnAuditedCompanyBalance(omember.ID); // if (oDashboardMember.Rows.Count > 0) // { // odrInfo = oDashboardData.NewRow(); // odrInfo["EmpCode"] = oDashboardMember.Rows[0]["EmpCode"].ToString(); // odrInfo["Name"] = oDashboardMember.Rows[0]["Name"].ToString(); // odrInfo["Designation"] = oDashboardMember.Rows[0]["Designation"].ToString(); // odrInfo["Department"] = oDashboardMember.Rows[0]["Department"].ToString(); // odrInfo["JoiningDate"] = oDashboardMember.Rows[0]["JoiningDate"].ToString(); // odrInfo["WithdrawalDate"] = (pFWithdrawalRequest != null && pFWithdrawalRequest.SettleDate != null) ? pFWithdrawalRequest.SettleDate : null; // odrInfo["WithdrawalStatus"] = (pFWithdrawalRequest != null) ? pFWithdrawalRequest.Status : EnumPFWithdrawalStatus.None; // odrInfo["MembershipDate"] = omember.MembershipDate; // odrInfo["DiscontinueDate"] = oDashboardMember.Rows[0]["DiscontinueDate"].ToString(); // odrInfo["EMAILADDRESS"] = oDashboardMember.Rows[0]["EMAILADDRESS"].ToString(); // odrInfo["MOBILENO"] = oDashboardMember.Rows[0]["EMAILADDRESS"].ToString(); // odrInfo["AuditedOwnBalance"] = auditedOwnBalance; // odrInfo["AuditedCompanyBalance"] = auditedCompanyBalance; // odrInfo["UnAuditedOwnBalance"] = unAuditedOwnBalance; // odrInfo["UnAuditedCompanyBalance"] = unAuditedCompanyBalance; // odrInfo["Conn"] = Ease.Core.Utility.Global.CipherFunctions.Decrypt("Cel.Admin", _fundEss.Value.MySqlCommandConnection);//_fundEss.Value.MySqlCommandConnection; // oDashboardData.Rows.Add(odrInfo); // } // } // catch (Exception ex) // { // //return ex; // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(oDashboardData); //} //[HttpGet] //[Route("getApproversForLoanApproval/{loanApplicationId}")] //public ActionResult GetApproversForLoanApproval(int loanApplicationId) //{ // LoanApplication loanApplication = new LoanApplicationService().GetLoanAppById(loanApplicationId); // Member LoanHr = _memberService.Get((int)loanApplication.HRUserID); // Member Trustee = _memberService.Get((int)loanApplication.TrusteesID); // Member SecondTrustee = _memberService.Get((int)loanApplication.SecondTrusteesID); // List _approvers = new List(); // try // { // _approvers.Add(LoanHr); // _approvers.Add(Trustee); // _approvers.Add(SecondTrustee); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(_approvers); //} //[HttpGet] //[Route("getApproversForPfDepositApproval")] //public ActionResult GetApproversForPfDepositApproval() //{ // Member PFDepositCheckedBy = _memberService.Get(_fundEss.Value.PFDepositCheckedBy); // Member PFDepositApprovedBy = _memberService.Get(_fundEss.Value.PFDepositApprovedBy); // List _approvers = new List(); // try // { // _approvers.Add(PFDepositCheckedBy); // _approvers.Add(PFDepositApprovedBy); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(_approvers); //} //[HttpPost] //[Route("updateLoanEarlySettlement")] //public ActionResult UpdateLoanEarlySettlement(FmLoan oLoan) //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // oLoan.ConnectionString = Ease.Core.Utility.Global.CipherFunctions.Decrypt("Cel.Admin", _fundEss.Value.MySqlCommandConnection); //_fundEss.Value.MySqlCommandConnection; // Member LoanHr = _memberService.Get(_fundEss.Value.LoanHrUser); // EmailSettings emailSettings = _emailSettings.Value; // try // { // if (oLoan.LoanEarlySettlementAttachment != null) // { // if (oLoan.LoanEarlySettlementAttachment.FileDataString != null) // { // string[] items = oLoan.LoanEarlySettlementAttachment.FileDataString.Split(new char[] { ',', ' ' }, StringSplitOptions.None); // byte[] newBytes = Convert.FromBase64String(items[1]); // oLoan.LoanEarlySettlementAttachment.FileDataString = ""; // oLoan.LoanEarlySettlementAttachment.FileData = newBytes; // } // } // if (oLoan.SettleStatus == EnumLoanSettleStatus.Deposited) // { // oLoan.DepositDate = DateTime.Now; // oLoan.ModifiedBy = currentUser.EmployeeID; // oLoan.ModifiedDate = DateTime.Now; // _fmLoanService.UpdateLoanEarlySettlement(oLoan); // string temperr = _fmLoanService.SendMailToLoanEarlySettlementHR(oLoan, emailSettings, LoanHr.ID); // //if (temperr != string.Empty) // //{ // // throw new Exception(temperr); // //} // } // else // { // oLoan.EarlySettleRequestBy = currentUser.MemberID; // LoanSettlestatus { None =1, request, Checked, deposited, settled} // oLoan.EarlySettleRequestDate = DateTime.Now; // oLoan.ModifiedBy = currentUser.EmployeeID; // oLoan.ModifiedDate = DateTime.Now; // _fmLoanService.UpdateLoanEarlySettlement(oLoan); // string temperr = _fmLoanService.SendMailToLoanEarlySettlementHR(oLoan, emailSettings, LoanHr.ID); // temperr = _fmLoanService.SendMailToLoanEarlySettleApplicant(oLoan, emailSettings); // //if (temperr != string.Empty) // //{ // // throw new Exception(temperr); // //} // } // return Ok(oLoan); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } //} //[HttpPost] //[Route("updateNewInvestment")] //public ActionResult UpdateNewInvestment(NewInvestment oNewInvestment) //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // try // { // Member Hr = _memberService.Get(_fundEss.Value.LoanHrUser); // _newInvestmentService.UpdateNewInvestmentApproval(oNewInvestment); // if (oNewInvestment.ApproverOneDate != null && oNewInvestment.ApproverTwoDate != null) // { // EmailSettings emailSettings = _emailSettings.Value; // string temperr = _newInvestmentService.SendMailToHr(emailSettings, Hr.ID); // } // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(oNewInvestment); //} //[HttpGet("getSelectedApproverForLoanApplication/{LoanApplicationID}")] //public ActionResult GetSelectedApproverForLoanApplication(int LoanApplicationID) //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // LoanApplication loanApplication = new LoanApplicationService().GetLoanAppById(LoanApplicationID); // Member LoanHr = _memberService.Get((int)loanApplication.HRUserID); // Member Trustee = _memberService.Get((int)loanApplication.TrusteesID); // Member SecondTrustee = _memberService.Get((int)loanApplication.SecondTrusteesID); // int selectedApprover = 0; // try // { // if (currentUser.MemberID == LoanHr.ID) // { // selectedApprover = 1; // } // else if (currentUser.MemberID == Trustee.ID) // { // selectedApprover = 2; // } // else if (currentUser.MemberID == SecondTrustee.ID) // { // selectedApprover = 3; // } // else // { // selectedApprover = 0; // } // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(selectedApprover); //} //[HttpGet("getSelectedApproverForPfMembershipWithdrawal")] //public ActionResult GetSelectedApproverForPfMembershipWithdrawal() //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // Member Trustee = _memberService.Get(_fundEss.Value.LoanTrustee); // Member SecondTrustee = _memberService.Get(_fundEss.Value.LoanSecondTrustee); // int selectedApprover = 0; // try // { // if (currentUser.MemberID == Trustee.ID) // { // selectedApprover = 1; // } // else if (currentUser.MemberID == SecondTrustee.ID) // { // selectedApprover = 2; // } // else // { // selectedApprover = 0; // } // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(selectedApprover); //} //[HttpPost] //[Route("getSelectedApproverForInvestment")] //public ActionResult GetSelectedApproverForInvestment(NewInvestment newInvestment) //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // int selectedApprover = 0; // try // { // if (currentUser.MemberID == newInvestment.ApproverOne) // { // selectedApprover = 1; // } // else if (currentUser.MemberID == newInvestment.ApproverTwo) // { // selectedApprover = 2; // } // else // { // selectedApprover = 0; // } // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(selectedApprover); //} //[HttpPost] //[Route("saveNewInvestment")] //public ActionResult SaveNewInvestment(NewInvestment newInvestment) //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // try // { // newInvestment. // _pfWithdrawalRequestService.Save(pFWithdrawalRequest); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(pFWithdrawalRequest); //} //[HttpGet("getPFWithdrawalRequest/{PFWithdrawalRequestID}")] //public ActionResult getPFWithdrawalRequest(int PFWithdrawalRequestID) //{ // PFWithdrawalRequest pFWithdrawalRequest = new PFWithdrawalRequest(); // try // { // pFWithdrawalRequest = _pfWithdrawalRequestService.Get(PFWithdrawalRequestID); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(pFWithdrawalRequest); //} //[HttpGet("getPFWithdrawalRequestByMemberID")] //public ActionResult getPFWithdrawalRequestByMemberID() //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // PFWithdrawalRequest pFWithdrawalRequest = new PFWithdrawalRequest(); // try // { // pFWithdrawalRequest = _pfWithdrawalRequestService.GetByMemberID(currentUser.MemberID); // } // catch (Exception ex) // { // return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); // } // return Ok(pFWithdrawalRequest); //} //[HttpPost] //[Route("viewPfWithdrawalRequestAttachmentPDF")] //public ActionResult viewPfWithdrawalRequestAttachmentPDF(PFWithdrawalRequest oPFWithdrawalRequest) //{ // PfWithdrawalRequestAttachment oPfWithdrawalRequestAttachment = new PfWithdrawalRequestAttachment(); // try // { // oPfWithdrawalRequestAttachment = _pfWithdrawalRequestService.LoadPfWithdrawalRequestAttachment(oPFWithdrawalRequest); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(oPfWithdrawalRequestAttachment); //} //[HttpPost] //[Route("viewLoanAttachmentPDF")] //public ActionResult viewLoanAttachmentPDF(PFWithdrawalRequest oPFWithdrawalRequest) //{ // PfWithdrawalRequestAttachment oPfWithdrawalRequestAttachment = new PfWithdrawalRequestAttachment(); // try // { // oPfWithdrawalRequestAttachment = _pfWithdrawalRequestService.LoadPfWithdrawalRequestAttachment(oPFWithdrawalRequest); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(oPfWithdrawalRequestAttachment); //} //[HttpPost("getLoanScheduleReport")] //public ActionResult getLoanScheduleReport(dynamic data) //{ // var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // Member omember = _memberService.Get(currentUser.MemberID); // int LoanId = (int)item["loanappid"].ToObject(); // byte[] bytes = null; // ReportProcessor reportProcessor = new ReportProcessor(); // LoanApplicationService loanApplicationService = new LoanApplicationService(); // try // { // bytes = new LoanReport().getLoanScheduleReport(LoanId, omember); // } // catch (Exception e) // { // return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // } // return Ok(bytes); //} //[HttpGet("getSystemDate")] //public ActionResult getSystemDate() //{ // CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); // DateTime lastMonthEndDate = new DateTime(); // //PFWithdrawalRequestService pFWithdrawalRequest = new PFWithdrawalRequestService(); // List dateTimeList = new List(); // //lastMonthEndDate = pFWithdrawalRequest.getSystemDate(currentUser.MemberID); // lastMonthEndDate = DateTime.Today; // dateTimeList.Add(GlobalFunctions.FirstDateOfMonth(lastMonthEndDate.AddMonths(+1))); // dateTimeList.Add(GlobalFunctions.LastDateOfMonth(lastMonthEndDate.AddMonths(+1))); // return Ok(dateTimeList); //} #endregion Commented Out Fund-related Codes [HttpPost("getMemberLedgerBalance")] public ActionResult GetMemberLedgerBalance(dynamic data) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); Member omember = _memberService.Get(currentUser.LoginID, _fundInfo.Value.FundConnection); var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); DateTime fromDate = item["fromDate"].ToObject(); DateTime toDate = item["toDate"].ToObject(); DataTable oIndividualMemConDataTable = new DataTable(); oIndividualMemConDataTable.Columns.Add("EmployeeNo", typeof(string)); oIndividualMemConDataTable.Columns.Add("Name", typeof(string)); oIndividualMemConDataTable.Columns.Add("Status", typeof(string)); oIndividualMemConDataTable.Columns.Add("Designation", typeof(string)); oIndividualMemConDataTable.Columns.Add("MonthOfContribution", typeof(string)); oIndividualMemConDataTable.Columns.Add("EPFInterest", typeof(double)).DefaultValue = 0.0; oIndividualMemConDataTable.Columns.Add("CPFInterest", typeof(double)).DefaultValue = 0.0; oIndividualMemConDataTable.Columns.Add("EPFContribution", typeof(double)).DefaultValue = 0.0; oIndividualMemConDataTable.Columns.Add("CPFContribution", typeof(double)).DefaultValue = 0.0; oIndividualMemConDataTable.Columns.Add("OpeningBalance", typeof(double)).DefaultValue = 0.0; oIndividualMemConDataTable.Columns.Add("Description", typeof(string)); oIndividualMemConDataTable.Columns.Add("Total", typeof(double)).DefaultValue = 0.0; try { DateTime tempTranDate = DateTime.MinValue; DataRow odr = null; DataRow odrInfo = null; double dOpeningBalance = 0.0; string searchCondition = string.Empty; if (omember != null) { searchCondition = SQLParser.MakeSQL(" and TranDate between %d and %d", fromDate, toDate); dOpeningBalance = _membersTransactionDetailsService.GetOpeningBalance(omember.ID, (int)EnumFundType.PF_EPF, fromDate, _fundInfo.Value.FundConnection); dOpeningBalance = dOpeningBalance + _membersTransactionDetailsService.GetOpeningBalance(omember.MemberID, (int)EnumFundType.PF_CPF, fromDate, _fundInfo.Value.FundConnection); List memTranDetailColl = _membersTransactionDetailsService.GetMemberContribution(omember.ID, searchCondition, _fundInfo.Value.FundConnection); foreach (MembersTransactionDetails memTranDetail in memTranDetailColl) { if (memTranDetail.Amount != 0) { odr = oIndividualMemConDataTable.NewRow(); odr["MonthOfContribution"] = memTranDetail.TranDate.ToString("dd MMM, yyyy"); EnumMemberTranType otrn = (EnumMemberTranType)memTranDetail.TranTypeID; odr["Description"] = (string)otrn.ToString().Replace("_", " "); if (memTranDetail.TranTypeID == (int)EnumMemberTranType.Monthly_Actual_Employee_Provident_Fund_Interest || memTranDetail.TranTypeID == (int)EnumMemberTranType.Opening_Actual_Employee_Provident_Fund_Interest || memTranDetail.TranTypeID == (int)EnumMemberTranType.Yearly_Actual_Employee_Provident_Fund_Interest || memTranDetail.TranTypeID == (int)EnumMemberTranType.Settlement_Interest_Employee_Provident_Fund || memTranDetail.TranTypeID == (int)EnumMemberTranType.Settlement_Interest_Company_Provident_Fund) { odr["EPFInterest"] = memTranDetail.Amount; } else if (memTranDetail.TranTypeID == (int)EnumMemberTranType.Monthly_Actual_Company_Provident_Fund_Interest || memTranDetail.TranTypeID == (int)EnumMemberTranType.Opening_Actual_Company_Provident_Fund_Interest || memTranDetail.TranTypeID == (int)EnumMemberTranType.Yearly_Actual_Company_Provident_Fund_Interest) { odr["CPFInterest"] = memTranDetail.Amount; } else if (EnumMemberTranType.Contribution_Of_Employee_Provident_Fund == (EnumMemberTranType)memTranDetail.TranTypeID || EnumMemberTranType.Opening_Employee_Provident_Fund == (EnumMemberTranType)memTranDetail.TranTypeID) { odr["EPFContribution"] = memTranDetail.Amount; } else if (EnumMemberTranType.Contribution_Of_Company_Provident_Fund == (EnumMemberTranType)memTranDetail.TranTypeID || EnumMemberTranType.Opening_Company_Provident_Fund == (EnumMemberTranType)memTranDetail.TranTypeID) { odr["CPFContribution"] = memTranDetail.Amount; } else if (EnumMemberTranType.Employee_Provident_Fund_LTA == (EnumMemberTranType)memTranDetail.TranTypeID) { odr["EPFContribution"] = memTranDetail.Amount; } else if (EnumMemberTranType.Company_Provident_Fund_LTA == (EnumMemberTranType)memTranDetail.TranTypeID) { odr["CPFContribution"] = memTranDetail.Amount; } else { continue; } odr["Total"] = memTranDetail.Amount; oIndividualMemConDataTable.Rows.Add(odr); } } odrInfo = oIndividualMemConDataTable.NewRow(); odrInfo["EmployeeNo"] = omember.EmpCode; odrInfo["Name"] = omember.Name; odrInfo["Status"] = omember.Status; odrInfo["Designation"] = omember.CurrentDesig; odrInfo["OpeningBalance"] = dOpeningBalance; odrInfo["EPFContribution"] = DBNull.Value; odrInfo["CPFContribution"] = DBNull.Value; odrInfo["EPFInterest"] = DBNull.Value; odrInfo["CPFInterest"] = DBNull.Value; oIndividualMemConDataTable.Rows.Add(odrInfo); } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } return Ok(oIndividualMemConDataTable); } [HttpPost("getMemberLedgerBalanceReport")] public ActionResult GetMemberLedgerBalanceReport(dynamic data) { CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); Member omember = _memberService.Get(currentUser.LoginID, _fundInfo.Value.FundConnection); var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); DateTime fromDate = item["fromDate"].ToObject(); DateTime toDate = item["toDate"].ToObject(); string reportType = item["reportType"].ToObject(); DataTable oIndividualMemConDataTable = new DataTable(); oIndividualMemConDataTable.Columns.Add("EmployeeNo", typeof(string)); oIndividualMemConDataTable.Columns.Add("Name", typeof(string)); oIndividualMemConDataTable.Columns.Add("Status", typeof(string)); oIndividualMemConDataTable.Columns.Add("Designation", typeof(string)); oIndividualMemConDataTable.Columns.Add("MonthOfContribution", typeof(string)); oIndividualMemConDataTable.Columns.Add("EPFInterest", typeof(double)).DefaultValue = 0.0; oIndividualMemConDataTable.Columns.Add("CPFInterest", typeof(double)).DefaultValue = 0.0; oIndividualMemConDataTable.Columns.Add("EPFContribution", typeof(double)).DefaultValue = 0.0; oIndividualMemConDataTable.Columns.Add("CPFContribution", typeof(double)).DefaultValue = 0.0; oIndividualMemConDataTable.Columns.Add("OpeningBalance", typeof(double)).DefaultValue = 0.0; oIndividualMemConDataTable.Columns.Add("Description", typeof(string)); oIndividualMemConDataTable.Columns.Add("Total", typeof(double)).DefaultValue = 0.0; DateTime tempTranDate = DateTime.MinValue; DataRow odr = null; double dOpeningBalance = 0.0; string searchCondition = string.Empty; try { if (omember != null) { searchCondition = SQLParser.MakeSQL(" and TranDate between %d and %d", fromDate, toDate); dOpeningBalance = _membersTransactionDetailsService.GetOpeningBalance(omember.ID, (int)EnumFundType.PF_EPF, fromDate, _fundInfo.Value.FundConnection); dOpeningBalance = dOpeningBalance + _membersTransactionDetailsService.GetOpeningBalance(omember.ID, (int)EnumFundType.PF_CPF, fromDate, _fundInfo.Value.FundConnection); odr = oIndividualMemConDataTable.NewRow(); odr["EmployeeNo"] = omember.EmpCode; odr["Designation"] = omember.CurrentDesig; odr["Name"] = omember.Name; odr["Status"] = omember.Status; oIndividualMemConDataTable.Rows.Add(odr); List memTranDetailColl = _membersTransactionDetailsService.GetMemberContribution(omember.ID, searchCondition, _fundInfo.Value.FundConnection); foreach (MembersTransactionDetails memTranDetail in memTranDetailColl) { if (memTranDetail.Amount != 0) { odr = oIndividualMemConDataTable.NewRow(); //odr["EmployeeNo"] = omember.EmpCode; //odr["Designation"] = omember.CurrentDesig; //odr["Name"] = omember.Name; //odr["Status"] = omember.Status; odr["MonthOfContribution"] = memTranDetail.TranDate.ToString("dd MMM, yyyy"); EnumMemberTranType otrn = (EnumMemberTranType)memTranDetail.TranTypeID; odr["Description"] = (string)otrn.ToString().Replace("_", " "); if (memTranDetail.TranTypeID == (int)EnumMemberTranType.Monthly_Actual_Employee_Provident_Fund_Interest || memTranDetail.TranTypeID == (int)EnumMemberTranType.Opening_Actual_Employee_Provident_Fund_Interest || memTranDetail.TranTypeID == (int)EnumMemberTranType.Yearly_Actual_Employee_Provident_Fund_Interest || memTranDetail.TranTypeID == (int)EnumMemberTranType.Settlement_Interest_Employee_Provident_Fund || memTranDetail.TranTypeID == (int)EnumMemberTranType.Settlement_Interest_Company_Provident_Fund) { odr["EPFInterest"] = memTranDetail.Amount; } else if (memTranDetail.TranTypeID == (int)EnumMemberTranType.Monthly_Actual_Company_Provident_Fund_Interest || memTranDetail.TranTypeID == (int)EnumMemberTranType.Opening_Actual_Company_Provident_Fund_Interest || memTranDetail.TranTypeID == (int)EnumMemberTranType.Yearly_Actual_Company_Provident_Fund_Interest) { odr["CPFInterest"] = memTranDetail.Amount; } else if (EnumMemberTranType.Contribution_Of_Employee_Provident_Fund == (EnumMemberTranType)memTranDetail.TranTypeID || EnumMemberTranType.Opening_Employee_Provident_Fund == (EnumMemberTranType)memTranDetail.TranTypeID) { odr["EPFContribution"] = memTranDetail.Amount; } else if (EnumMemberTranType.Contribution_Of_Company_Provident_Fund == (EnumMemberTranType)memTranDetail.TranTypeID || EnumMemberTranType.Opening_Company_Provident_Fund == (EnumMemberTranType)memTranDetail.TranTypeID) { odr["CPFContribution"] = memTranDetail.Amount; } else if (EnumMemberTranType.Employee_Provident_Fund_LTA == (EnumMemberTranType)memTranDetail.TranTypeID) { odr["EPFContribution"] = memTranDetail.Amount; } else if (EnumMemberTranType.Company_Provident_Fund_LTA == (EnumMemberTranType)memTranDetail.TranTypeID) { odr["CPFContribution"] = memTranDetail.Amount; } else { continue; } odr["Total"] = memTranDetail.Amount; oIndividualMemConDataTable.Rows.Add(odr); } } } } catch (Exception ex) { return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); } oIndividualMemConDataTable.TableName = "FundEssDataSet_MemberBalanceLedger"; DataSet resultDataSet = new DataSet(); resultDataSet.Tables.Add(oIndividualMemConDataTable); string RDLCName = "HRM.Report.RDLC.rptIndividualMemberConForKCCL.rdlc"; List rParamList = new List(); ReportParameter rParam = new ReportParameter("OpeningBalance", dOpeningBalance.ToString("#,##0.00")); rParamList.Add(rParam); rParam = new ReportParameter("fromDate", fromDate.ToString("dd MMM, yyyy")); rParamList.Add(rParam); rParam = new ReportParameter("toDate", toDate.ToString("dd MMM, yyyy")); rParamList.Add(rParam); ReportProcessor reportProcessor = new ReportProcessor(); byte[] bytes = null; bytes = reportProcessor.CommonReportView(null, RDLCName, resultDataSet, null, rParamList, true, 1, reportType); return Ok(bytes); } } }