HRM-10/HRM.UI/Controllers/Recruitment/RecruitmentController.cs

4636 lines
197 KiB
C#
Raw Normal View History

2026-11-03 13:06:00 +06:00
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using HRM.BO;
using HRM.DA;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Configuration;
using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using NPOI.HPSF;
using System.Text.RegularExpressions;
using static System.Runtime.InteropServices.JavaScript.JSType;
using Path = System.IO.Path;
using static iTextSharp.text.pdf.AcroFields;
using System.Reflection;
using MySqlX.XDevAPI.Common;
using Microsoft.AspNetCore.Http.HttpResults;
using UglyToad.PdfPig;
using UglyToad.PdfPig.Content;
using UglyToad.PdfPig.XObjects;
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
using Array = System.Array;
using static HRM.BO.RecJobTracking;
using MySqlX.XDevAPI;
using NPOI.POIFS.Crypt.Dsig;
using HRM.BO.Configuration;
using NPOI.SS.Formula.Functions;
using System.Net.Mail;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Schema;
using UglyToad.PdfPig.Graphics.Operations.PathPainting;
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace HRM.UI.Controllers
{
[ApiController]
[Route("api/Recruitment")]
[Authorize]
public class RecruitmentController : Controller
{
#region Declerations
private readonly ICVService _cvService;
private readonly IHeadCountApprovalRequestService _headCountApprovalRequestService;
private readonly IInternalRecruitmentService _internalRecruitmentService;
private readonly ICandidateService _candidateService;
private readonly IRecruitementProcessService _recruitementProcessService;
private readonly IRecruitmentLettersService _recruitementLettterService;
private readonly IConfiguration _config;
private readonly IEmployeeService _employeeService;
private readonly IErCircularService _erCircularService;
private readonly IErAppliedApplicantService _erAppliedApplicantService;
private readonly IErCVService _ercvService;
private readonly IRecJobTrackingService _recJobTrackingService;
private readonly IEducationLevelService _educationLevelService;
private readonly IDisciplineService _disciplineService;
private readonly IInterviewAssessmentKPIService _interviewAssessmentKPIService;
private static string _filePath = @"ClientApp\Documents\";
private static string _generatedPath = @"ClientApp\Documents\";
private readonly IOptions<EmailSettings> _emailSettings;
#endregion
#region Constructor
public RecruitmentController(IConfiguration config,
ICVService cvService,
IHeadCountApprovalRequestService headCountService,
IInternalRecruitmentService internalRecruitmentService,
ICandidateService candidateService, IRecruitementProcessService recruitementProcessService,
IEmployeeService employeeService
, IRecruitmentLettersService recruitementLettterService,
IErCircularService erCircularService,
IErAppliedApplicantService erAppliedApplicantService,
IRecJobTrackingService recJobTrackingService,
IEducationLevelService educationLevelService,
IDisciplineService disciplineService,
IErCVService ercvService, IInterviewAssessmentKPIService interviewAssessmentKPIService,
IOptions<EmailSettings> emailSettings)
{
_config = config;
_cvService = cvService;
_headCountApprovalRequestService = headCountService;
_internalRecruitmentService = internalRecruitmentService;
_candidateService = candidateService;
this._recruitementProcessService = recruitementProcessService;
this._recruitementLettterService = recruitementLettterService;
_employeeService = employeeService;
_erCircularService = erCircularService;
_erAppliedApplicantService = erAppliedApplicantService;
_ercvService = ercvService;
_recJobTrackingService = recJobTrackingService;
this._educationLevelService = educationLevelService;
this._disciplineService = disciplineService;
_interviewAssessmentKPIService = interviewAssessmentKPIService;
this._emailSettings = emailSettings;
}
#endregion
[HttpGet]
[Route("getCVById/{cvId}")]
public ActionResult getCVById(int cvID)
{
CV oCV = new CV();
try
{
oCV = _cvService.Get(cvID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oCV);
}
[HttpPost]
[Route("getCVsByIds")]
public ActionResult getCVsByIds(dynamic cvIds)
{
List<CV> oCVs = new List<CV>();
List<int> cvids = Newtonsoft.Json.JsonConvert.DeserializeObject<List<int>>(cvIds.ToString());
string strIDs = "";
cvids.ForEach(x => { strIDs = strIDs + x + ","; });
try
{
if (strIDs.Length > 0)
{
strIDs = strIDs.Substring(0, strIDs.Length - 1);
oCVs = _cvService.GetCVByIDs(strIDs);
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oCVs);
}
[HttpGet]
[Route("getFileAttachments/{cvID}")]
public ActionResult getFileAttachments(int cvID)
{
List<FileAttachment> attachments = null;
try
{
attachments = _cvService.GetAllAttachments(cvID, EnumFileType.CV);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(attachments);
}
[HttpGet]
[Route("dtGetCVByID/{cvId}")]
public ActionResult dtGetCVByID(int cvID)
{
DataTable oCV = new DataTable();
try
{
oCV = _cvService.dtGetCVByID(cvID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oCV);
}
//getAllCV getAllCV
[Route("getAllCV")]
public ActionResult getAllCV()
{
List<CV> oCVs = new List<CV>();
try
{
oCVs = _cvService.Get();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oCVs);
}
//getAllOnlyCV
[Route("getAllOnlyCV")]
public ActionResult getAllOnlyCV()
{
List<CV> oCVs = new List<CV>();
try
{
oCVs = _cvService.getAllOnlyCV();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oCVs);
}
[Route("getCVs")]
public ActionResult getCVs()
{
List<CV> oCVs = new List<CV>();
try
{
oCVs = _cvService.GetCVs();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oCVs);
}
[Route("getCvInfo/{name}/{mobile}/{email}/{institute}/{degreeTitleId}")]
public ActionResult getCvInfo(string name, string mobile, string email, string institute, int degreeTitleId)
{
name = (name == "undefined" || name == "null") ? string.Empty : name;
email = (email == "undefined" || email == "null") ? string.Empty : email;
mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile;
institute = (institute == "undefined" || institute == "null") ? string.Empty : institute;
List<CV> oCVs = new List<CV>();
try
{
oCVs = _cvService.GetCVs(name, email, mobile, institute, degreeTitleId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oCVs);
}
[Route("getOnlinePortalCVs/{requisitionID}")]
public ActionResult GetOnlinePortalCVs(int requisitionID)
{
List<CV> oCVs = new List<CV>();
try
{
oCVs = _cvService.GetOnlinePortalCVs(requisitionID);
//if(oCVs != null)
//{
// foreach(var item in oCVs)
// {
// item.Details = "Name: " + item.Name + Environment.NewLine + "Mobile: " + item.Mobile + Environment.NewLine + "Email: " + item.Email + Environment.NewLine + "Expected Salary: ";
// if(item.AllEduQualifications != null && item.AllEduQualifications.Count > 0)
// {
// foreach(var education in item.AllEduQualifications)
// {
// var educationalDetail = "Degree Name: "+ education.EducationLevels.Find(x=>x.ID == education.DegreeTitleID).Description
// }
// }
// }
//}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oCVs);
}
[HttpGet]
[Route("getAllSearchedCV/{name}/{email}/{mobile}")]
public ActionResult GetAllSearchedCV(string name, string email, string mobile)
{
name = (name == "undefined" || name == "null") ? string.Empty : name;
email = (email == "undefined" || email == "null") ? string.Empty : email;
mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile;
List<CV> cvs = new List<CV>();
try
{
cvs = _cvService.GetAllSearchedCV(name, email, mobile, null, null);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(cvs);
}
[HttpGet]
[Route("GetByCvSearch/{name}/{email}/{mobile}")]
public ActionResult GetByCvSearch(string name, string email, string mobile)
{
name = (name == "undefined" || name == "null") ? string.Empty : name;
email = (email == "undefined" || email == "null") ? string.Empty : email;
mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile;
List<CV> cvs = new List<CV>();
try
{
cvs = _cvService.GetByCvSearch(name, email, mobile);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(cvs);
}
[HttpPost]
[Route("saveHeadCount")]
public ActionResult saveHeadCount(HeadCountApprovalRequest ob)
{
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
ob.CreatedBy = currentUser.UserID;
ob.RequestDate = Ease.Core.Utility.Global.DateFunctions.LastDateOfYear(ob.RequestDate);
_headCountApprovalRequestService.Save(ob);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveHeadCountsData")]
public ActionResult saveHeadCountsData(List<HeadCountApprovalRequest> items)
{
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
foreach (var item in items)
{
item.CreatedBy = currentUser.UserID;
item.CategoryID = null;
}
_headCountApprovalRequestService.SaveAuto(items);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteHeadCount")]
public ActionResult deleteHeadCount(HeadCountApprovalRequest ob)
{
try
{
_headCountApprovalRequestService.Delete(ob.ID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteCv")]
public ActionResult deleteCv(CV ob)
{
try
{
_cvService.Delete(ob);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteReceuitmentCv")]
public ActionResult deleteReceuitmentCv(CV ob)
{
try
{
_candidateService.DeleteCandidateCVCollection(ob.CandidateID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpGet]
[Route("getAllHeadCount")]
public ActionResult getAllHeadCount()
{
List<HeadCountApprovalRequest> oHeadCountApprovalRequests = new List<HeadCountApprovalRequest>();
try
{
oHeadCountApprovalRequests = _headCountApprovalRequestService.Get();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oHeadCountApprovalRequests);
}
[HttpGet]
[Route("getApprovdRecruitmentPicker/{approvalStatus}/{offerLetterStatus}/{onBoardStatus}")]
public ActionResult getApprovdRecruitmentPicker(EnumRequisitionApprovalStatus? approvalStatus, EnumOfferLetterStatus? offerLetterStatus, string onBoardStatus)
{
List<InternalRecruitment> oInternalRecuitmentList = new List<InternalRecruitment>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<Grade> grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
List<Designation> designations = new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
List<Department> departments = new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
List<Location> locations = new LocationService().Get(EnumStatus.Active, (int)currentUser.PayrollTypeID);
onBoardStatus = (onBoardStatus == "undefined" || onBoardStatus == "null") ? string.Empty : onBoardStatus;
try
{
oInternalRecuitmentList = _internalRecruitmentService.GetApprovedRequisitionsPicker(approvalStatus, offerLetterStatus, onBoardStatus);
if (oInternalRecuitmentList != null && oInternalRecuitmentList.Count > 0)
{
oInternalRecuitmentList.ForEach(x =>
{
var grd = grades.FirstOrDefault(d => d.ID == x.GradeId);
if (grd != null) x.GradeCode = grd.Code;
var designation = designations.FirstOrDefault(d => d.ID == x.DesignationId);
if (designation != null) x.DesignationName = designation.Name;
var department = departments.FirstOrDefault(d => d.ID == x.DepartmentId);
if (department != null)
{
x.DepartmentCode = department.Code;
x.DepartmentName = department.Name;
}
var location = locations.FirstOrDefault(d => d.ID == x.LocationId);
if (location != null)
{
x.LocationName = location.Name;
}
x.RequisitionApprovalStatusString = EnumHelper.GetEnumDescription(x.RequisitionApprovalStatus);
});
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oInternalRecuitmentList);
}
[HttpPost]
[Route("saveInternalRecruitment")]
public ActionResult SaveInternalRecruitment(InternalRecruitment item)
{
//var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString");
// string connectionString = Startup
string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
//string connectionString = "";
int ans;
var isNew = item.ID <= 0;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (isNew)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
try
{
ans = _internalRecruitmentService.Save(item, connectionString);
if (ans > 0 && currentUser.EmployeeID != null && item.RequisitionApprovalStatus == EnumRequisitionApprovalStatus.Not_Initiated)
{
_internalRecruitmentService.InitiateRecruitmentRequisitionWorkFlow(item, (int)currentUser.EmployeeID, item.CreatedBy);
}
if (ans > 0 && (item.RequisitionApprovalStatus == EnumRequisitionApprovalStatus.Approved || item.RequisitionApprovalStatus == EnumRequisitionApprovalStatus.Decline))
{
_internalRecruitmentService.UpdateRequisitionApproveStatusAdmin(item, item.CreatedBy);
}
if (item.IRFileAttacments != null && item.IRFileAttacments.Count > 0)
{
foreach (var file in item.IRFileAttacments)
{
if (System.IO.File.Exists(file.FilePath))
{
System.IO.File.Delete(file.FilePath);
}
}
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ans);
}
[HttpPost]
[Route("InitiateOfferLetterWorkFlow")]
public ActionResult InitiateOfferLetterWorkFlow(InternalRecruitment item)
{
//var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString");
// string connectionString = Startup
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
if (currentUser.EmployeeID == null)
throw new Exception("Employee ID of Current User not found");
item.offLttrAppRaiseEmpID = (int)currentUser.EmployeeID;
_internalRecruitmentService.InitiateOfferLetterWorkFlow(item, item.offLttrAppRaiseEmpID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("ApproveOfferLetterStatus")]
public ActionResult ApproveOfferLetterStatus(InternalRecruitment item)
{
//var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString");
// string connectionString = Startup
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
if (currentUser.EmployeeID == null)
throw new Exception("Employee ID of Current User not found");
item.offLttrAppRaiseEmpID = (int)currentUser.EmployeeID;
_internalRecruitmentService.ApproveOfferLetterStatus(item, item.offLttrAppRaiseEmpID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("ApproveOfferLetterStatusByRequisitionId")]
public ActionResult ApproveOfferLetterStatusByRequisitionId([FromBody] int requisitionId)
{
//var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString");
// string connectionString = Startup
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
_internalRecruitmentService.ApproveOfferLetterStatusByRequisitionId(requisitionId, (int)currentUser.EmployeeID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("SendDepartmentApproval")]
public ActionResult SendDepartmentApproval(dynamic data)
{
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
DateTime deptSendApprovalDate = items["deptSendApprovalDate"] == null ? false : items["deptSendApprovalDate"].ToObject<DateTime>();
int recruitmentId = items["reqId"] == null ? 0 : items["reqId"].ToObject<int>();
if (recruitmentId > 0)
{
_cvService.UpdateDeptApprovalInRecruitmentCandidate(recruitmentId, deptSendApprovalDate, (int)currentUser.EmployeeID);
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("ApproveOfferLetter")]
public ActionResult ApproveOfferLetter(WFMovementTran otran)
{
//var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString");
// string connectionString = Startup
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
otran.FromEmployeeID = (int)currentUser.EmployeeID;
try
{
_internalRecruitmentService.ApproveOfferLetter(otran);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("ApproveRequisition")]
public ActionResult ApproveRequisition(WFMovementTran otran)
{
//var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString");
// string connectionString = Startup
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
otran.FromEmployeeID = (int)currentUser.EmployeeID;
try
{
_internalRecruitmentService.ApproveRecruitmentRequisition(otran);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("RejectRecruitmentRequisition")]
public ActionResult RejectRecruitmentRequisition(WFMovementTran otran)
{
//var connectionString = _config.GetConnectionString("DbContextSettings:ConnectionString");
// string connectionString = Startup
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
otran.FromEmployeeID = (int)currentUser.EmployeeID;
try
{
_internalRecruitmentService.RecruitmentRequisitionReject(otran);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpGet]
[Route("getAllInternalRecruitment/{fromDate}/{toDate}/{type}")]
public ActionResult getAllInternalRecruitment(DateTime? fromDate, DateTime? toDate, int type)
{
List<InternalRecruitment> oInternalRecuitmentList = new List<InternalRecruitment>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<Grade> grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
List<Designation> designations =
new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
List<Department> departments =
new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
EnumInternalRecruitmentType stype = (EnumInternalRecruitmentType)type;
try
{
oInternalRecuitmentList = _internalRecruitmentService.Get(fromDate, toDate, stype);
if (oInternalRecuitmentList != null && oInternalRecuitmentList.Count > 0)
{
oInternalRecuitmentList.ForEach(x =>
{
var grd = grades.FirstOrDefault(d => d.ID == x.GradeId);
if (grd != null) x.GradeCode = grd.Code;
var designation = designations.FirstOrDefault(d => d.ID == x.DesignationId);
if (designation != null) x.DesignationName = designation.Name;
var department = departments.FirstOrDefault(d => d.ID == x.DepartmentId);
if (department != null)
{
x.DepartmentCode = department.Code;
x.DepartmentName = department.Name;
}
});
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oInternalRecuitmentList);
}
[HttpGet]
[Route("getemployeeWiseRecruitment/{fromDate}/{toDate}/{type}")]
public ActionResult getemployeeWiseRecruitment(DateTime? fromDate, DateTime? toDate, int type)
{
List<InternalRecruitment> oInternalRecuitmentList = new List<InternalRecruitment>();
List<InternalRecruitment> finalList = new List<InternalRecruitment>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<Grade> grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
List<Designation> designations =
new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
List<Department> departments =
new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
EnumInternalRecruitmentType stype = (EnumInternalRecruitmentType)type;
try
{
oInternalRecuitmentList = _internalRecruitmentService.Get(fromDate, toDate, stype);
if (oInternalRecuitmentList != null && oInternalRecuitmentList.Count > 0)
{
oInternalRecuitmentList.ForEach(x =>
{
var grd = grades.FirstOrDefault(d => d.ID == x.GradeId);
if (grd != null) x.GradeCode = grd.Code;
var designation = designations.FirstOrDefault(d => d.ID == x.DesignationId);
if (designation != null) x.DesignationName = designation.Name;
var department = departments.FirstOrDefault(d => d.ID == x.DepartmentId);
if (department != null)
{
x.DepartmentCode = department.Code;
x.DepartmentName = department.Name;
}
});
}
finalList = oInternalRecuitmentList.Where(y => y.RaisedBy == currentUser.UserID).ToList();
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(finalList);
}
[HttpGet]
[Route("getInternalRecruitmentByID/{recruitmentId}")]
public ActionResult getInternalRecruitmentByID(int recruitmentId)
{
InternalRecruitment oInternalRecuitment = new InternalRecruitment();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<Grade> grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
List<Designation> designations =
new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
List<Department> departments =
new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
try
{
oInternalRecuitment = _internalRecruitmentService.Get(recruitmentId);
if (oInternalRecuitment != null)
{
var grd = grades.FirstOrDefault(d => d.ID == oInternalRecuitment.GradeId);
if (grd != null) oInternalRecuitment.GradeCode = grd.Code;
var designation = designations.FirstOrDefault(d => d.ID == oInternalRecuitment.DesignationId);
if (designation != null) oInternalRecuitment.DesignationName = designation.Name;
var department = departments.FirstOrDefault(d => d.ID == oInternalRecuitment.DepartmentId);
if (department != null) oInternalRecuitment.DepartmentCode = department.Code;
oInternalRecuitment.IREmployees = new List<IREmployee>();
oInternalRecuitment.IREmployees = _internalRecruitmentService.GetIREmployeess(recruitmentId);
foreach (var ir in oInternalRecuitment.IREmployees)
{
ir.Employee = _employeeService.Get(ir.EmployeeID);
}
oInternalRecuitment.IRFileAttacments = new List<FileAttachment>();
oInternalRecuitment.IRFileAttacments =
_internalRecruitmentService.GetIRFileAttachments(recruitmentId);
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oInternalRecuitment);
}
[HttpPost]
[Route("get-download-file")]
[AllowAnonymous]
[IgnoreAntiforgeryToken]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> GetDownloadFile(dynamic data)
{
string contentType = "";
var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
try
{
List<FileAttachment> IRFileAttacments = new List<FileAttachment>();
IRFileAttacments =
_internalRecruitmentService.GetIRFileAttachmentbyID((int)item.id, (int)item.fileId);
Stream memory = new MemoryStream();
if (IRFileAttacments != null && IRFileAttacments.Count > 0)
{
byte[] buffer = new byte[16 * 1024];
contentType = GetFileType(IRFileAttacments[0].OriginalFileName);
buffer = IRFileAttacments[0].FileAsByteArray;
return File(buffer, contentType, IRFileAttacments[0].OriginalFileName);
}
else
{
throw new Exception("File Download error");
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
}
[HttpPost]
[Route("get-download-file-cv")]
[AllowAnonymous]
[IgnoreAntiforgeryToken]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> GetDownloadFileCV(dynamic data)
{
string contentType = "";
var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
try
{
List<FileAttachment> IRFileAttacments = new List<FileAttachment>();
IRFileAttacments =
_internalRecruitmentService.GetIRFileAttachmentbyIDCV((int)item.id, (int)item.fileId,
EnumFileType.CV);
Stream memory = new MemoryStream();
if (IRFileAttacments != null && IRFileAttacments.Count > 0)
{
byte[] buffer = new byte[16 * 1024];
contentType = GetFileType(IRFileAttacments[0].OriginalFileName);
buffer = IRFileAttacments[0].FileAsByteArray;
return File(buffer, contentType, IRFileAttacments[0].OriginalFileName);
}
else
{
throw new Exception("File Download error");
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
}
2026-11-04 19:03:36 +06:00
//[HttpPost]
//[Route("get-file-type")]
//[AllowAnonymous]
//[IgnoreAntiforgeryToken]
//[ProducesResponseType(StatusCodes.Status200OK)]
public string GetFileType(string originalFileName)
{
//var item = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
//string fileName = (string)item["fileName"].ToObject<string>();
string fileName = originalFileName;
string contentType;
new FileExtensionContentTypeProvider().TryGetContentType(fileName, out contentType);
return contentType ?? "application/octet-stream";
}
[HttpPost]
2026-11-03 13:06:00 +06:00
[Route("saveCV")]
public ActionResult saveCV(CV ob)
{
try
{
//string connectionString = "";
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
ob.CreatedBy = currentUser.UserID;
string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
if (ob != null)
{
if (ob.ID <= 0 && ob.CVProfilePhoto.PreviousFileTobase64 != null)
{
string[] items = ob.CVProfilePhoto.PreviousFileTobase64.Split(new char[] { ',', ' ' }, StringSplitOptions.None);
byte[] newBytes = Convert.FromBase64String(items[1]);
ob.CVProfilePhoto.FileAsByteArray = newBytes;
}
}
_cvService.Save(ob, connectionString);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveErCV")]
public ActionResult saveErCV(ErCV ob)
{
try
{
//string connectionString = "";
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
ob.CreatedBy = currentUser.UserID;
ob.UserID = currentUser.UserID;
string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
if (ob != null)
{
if (ob.ID <= 0 && ob.ErCVProfilePhoto.PreviousFileTobase64 != null)
{
string[] items = ob.ErCVProfilePhoto.PreviousFileTobase64.Split(new char[] { ',', ' ' }, StringSplitOptions.None);
byte[] newBytes = Convert.FromBase64String(items[1]);
ob.ErCVProfilePhoto.FileAsByteArray = newBytes;
}
}
_ercvService.Save(ob, connectionString);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveMultipleCV")]
public ActionResult saveMultipleCV(List<CV> cvs)
{
List<CV> allCVs = new List<CV>();
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
foreach (var item in cvs)
{
var isNew = item.ID <= 0;
if (isNew)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
}
string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
allCVs = _cvService.SaveCVs(cvs);
if (allCVs != null)
{
foreach (var item in cvs)
{
if (item.IRFileAttacments != null && item.IRFileAttacments.Count > 0)
{
foreach (var file in item.IRFileAttacments)
{
if (System.IO.File.Exists(file.FilePath))
{
System.IO.File.Delete(file.FilePath);
}
}
}
}
}
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(allCVs);
}
[HttpGet]
[Route("GetCVByIDs/{cvIds}")]
public ActionResult GetCVByID(string cvIds)
{
List<CV> allCVs = new List<CV>();
try
{
allCVs = _cvService.GetCVByIDs(cvIds);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(allCVs);
}
[HttpPost]
[Route("saveCVSort")]
public ActionResult saveCVSort(List<CVSort> cvsorts)
{
// List<CV> allCVs = new List<CV>();
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
foreach (var item in cvsorts)
{
var isNew = item.ID <= 0;
if (isNew)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
}
//string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
_cvService.SaveCVSort(cvsorts);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("UpdateCandidateAndSaveCvSort")]
public ActionResult UpdateCandidateAndSaveCvSort(dynamic data)
{
List<CVSort> cvsorts = new List<CVSort>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
cvsorts = items["cvSorts"] == null ? null : (List<CVSort>)items["cvSorts"].ToObject<List<CVSort>>();
bool sendMailStatus = items["sendMail"] == null ? false : items["sendMail"].ToObject<bool>();
CV cv = null;
//cv = items["cv"] == null ? null : (CV)items["cv"].ToObject<CV>();
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
Employee user = new EmployeeService().Get((int)currentUser.EmployeeID);
string userDept = string.Empty;
string userDes = string.Empty;
if (user != null)
{
userDept = (new DepartmentService().Get((int)user.DepartmentID))?.Name;
userDes = (new DesignationService().Get((int)user.DesignationID)).Name;
}
foreach (var item in cvsorts)
{
var isNew = item.ID <= 0;
if (isNew)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
}
//string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
if (cv != null)
{
//Candidate candidate = new Candidate();
//candidate = _candidateService.GetCanditatebyCvID(cv.ID, cv.PositionID);
//if (candidate != null)
//{
// candidate.PrimarySelected = true;
// _candidateService.UpdateSelection(candidate);
//}
}
_cvService.SaveCVSort(cvsorts);
if (sendMailStatus)
{
InternalRecruitment rq = new InternalRecruitmentService().Get(cvsorts[0].RequisitionID);
Department dept = new DepartmentService().Get(rq.DepartmentId);
EmailSettings emailSettings = _emailSettings.Value;
foreach (CVSort cvsort in cvsorts)
{
Employee emp = _employeeService.Get(cvsort.EmployeeID);
if(emp != null && rq != null && dept != null)
{
MailSender mailSender = new MailSender();
mailSender.AddTo(emp.EmailAddress.Trim());
//mailSender.Subject = "CV short list for: " + rq.PositionName + " under " + dept.Name;
mailSender.Subject = "Request for Shortlisting Candidates in HRIS";
mailSender.Body = "<p> Dear Sir/Madam,</p>";
mailSender.Body = "<p> We hope you are doing well.</p>";
mailSender.Body += "<p> We have received applications for the " + rq.PositionName + " position under " + dept.Name+" department and have pre-screened candidates based on the required qualifications. The shortlisted CVs have been uploaded to the HRIS recruitment module for your review.</p>";
mailSender.Body += "<p> Kindly go through the profiles and update the system with your feedback and shortlisted candidates by "+ Convert.ToDateTime(cvsort.CvSelectionCompleteDate).ToString("dd MMMM yyyy") + ". Please let us know if you require any further information or assistance.</p>";
mailSender.Body += "<p> Looking forward to your response." + "</p>";
mailSender.Body += "<p> Thanks," + "</p>";
mailSender.Body += "<p> "+user.Name+ "</p>";
mailSender.Body += "<p> " + userDes + "</p>";
mailSender.SendMail(emailSettings);
System.Threading.Thread.Sleep(500);
}
}
}
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("UpdateRating")]
public ActionResult UpdateRating(dynamic odata)
{
List<CVSort> cvsorts = new List<CVSort>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(odata));
int candidateID = items["candidateID"] == null ? 0 : items["candidateID"].ToObject<int>();
if(candidateID <= 0)
candidateID = items["candidateId"] == null ? 0 : items["candidateId"].ToObject<int>();
int rating = items["rating"] == null ? 0 : items["rating"].ToObject<int>();
try
{
_candidateService.UpdateRating(candidateID, rating);
//_cvService.SaveCVSort(cvsorts);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("UpdateSortList")]
public ActionResult UpdateSortList(dynamic odata)
{
List<CVSort> cvsorts = new List<CVSort>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(odata));
int candidateID = items["candidateID"] == null ? 0 : items["candidateID"].ToObject<int>();
bool selected = items["primarySelected"] == null ? false : items["primarySelected"].ToObject<bool>();
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
_candidateService.UpdatePrimarySelection(candidateID, selected, (int)currentUser.EmployeeID);
//_cvService.SaveCVSort(cvsorts);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("updateDeptSelectedChange")]
public ActionResult UpdateDeptSelectedChange(dynamic odata)
{
List<CVSort> cvsorts = new List<CVSort>();
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(odata));
int candidateID = items["candidateID"] == null ? 0 : items["candidateID"].ToObject<int>();
bool deptSelected = items["deptSelected"] == null ? false : items["deptSelected"].ToObject<bool>();
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
_candidateService.UpdateDeptSelection(candidateID, deptSelected, (int)currentUser.EmployeeID);
//_cvService.SaveCVSort(cvsorts);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpGet]
[Route("completeCVSortEss/{reqId}")]
public ActionResult completeCVSortEss(int reqId)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
_candidateService.CompleteCVSortEss(reqId, (int)currentUser.EmployeeID);
//_cvService.SaveCVSort(cvsorts);
//SendMail to Recruiter
InternalRecruitment ir = new InternalRecruitmentService().Get(reqId);
var recJobTracking = new RecJobTrackingService().GetByRecruitmentId(reqId);
if (recJobTracking != null)
{
Employee recruiter = new EmployeeService().Get(recJobTracking.RecruiterID);
Employee emp = new EmployeeService().Get((int)currentUser.EmployeeID);
if(ir!=null && recruiter!=null && emp != null)
{
Department dept = new DepartmentService().Get(ir.DepartmentId);
EmailSettings emailSettings = _emailSettings.Value;
MailSender mailSender = new MailSender();
mailSender.AddTo(recruiter.EmailAddress.Trim());
mailSender.Subject = "CV short list completed by "+ emp.Name+ " for: " + ir.PositionName + " under " + dept.Name;
mailSender.Body = "<p> Dear Sir/Madam, </p>";
mailSender.Body += "<p><b>"+ emp.Name+"</b>, Hiring Manager has completed the CV shortlist process for: " + ir.PositionName +" under "+ dept.Name+ " Department.</p>";
mailSender.Body += "<p> Thank You" + "</p>";
mailSender.SendMail(emailSettings);
System.Threading.Thread.Sleep(500);
}
}
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("updateOfferLetterCandidateDeptSelectionCompleteDate")]
public ActionResult UpdateOfferLetterCandidateDeptSelectionCompleteDate([FromBody] int reqId)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
_candidateService.UpdateOfferLetterCandidateDeptSelectionCompleteDate(reqId);
//_cvService.SaveCVSort(cvsorts);
//SendMail to Recruiter
InternalRecruitment ir = new InternalRecruitmentService().Get(reqId);
var recJobTracking = new RecJobTrackingService().GetByRecruitmentId(reqId);
if (recJobTracking != null)
{
Employee recruiter = new EmployeeService().Get(recJobTracking.RecruiterID);
Employee emp = new EmployeeService().Get((int)currentUser.EmployeeID);
if (ir != null && recruiter != null && emp != null)
{
Department dept = new DepartmentService().Get(ir.DepartmentId);
EmailSettings emailSettings = _emailSettings.Value;
MailSender mailSender = new MailSender();
mailSender.AddTo(recruiter.EmailAddress.Trim());
mailSender.Subject = "Candidate Selection for Offer Letter completed by " + emp.Name + " for: " + ir.PositionName + " under " + dept.Name;
mailSender.Body = "<p> Dear Sir/Madam, </p>";
mailSender.Body += "<p><b>" + emp.Name + "</b>, Hiring Manager has completed the Candidate Selection process of Offer Letter for: " + ir.PositionName + " under " + dept.Name + " Department.</p>";
mailSender.Body += "<p> Thank You" + "</p>";
mailSender.SendMail(emailSettings);
System.Threading.Thread.Sleep(500);
}
}
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("updateOfferLetterMgtApprovalDate")]
public ActionResult UpdateOfferLetterMgtApprovalDate([FromBody] int reqId)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
_candidateService.UpdateOfferLetterMgtApprovalDate(reqId);
//SendMail to Recruiter
//InternalRecruitment ir = new InternalRecruitmentService().Get(reqId);
//var recJobTracking = new RecJobTrackingService().GetByRecruitmentId(reqId);
//if (recJobTracking != null)
//{
// Employee recruiter = new EmployeeService().Get(recJobTracking.RecruiterID);
// Employee emp = new EmployeeService().Get((int)currentUser.EmployeeID);
// if (ir != null && recruiter != null && emp != null)
// {
// Department dept = new DepartmentService().Get(ir.DepartmentId);
// EmailSettings emailSettings = _emailSettings.Value;
// MailSender mailSender = new MailSender();
// mailSender.AddTo(recruiter.EmailAddress.Trim());
// mailSender.Subject = "Candidate Selection for Offer Letter completed by " + emp.Name + " for: " + ir.PositionName + " under " + dept.Name;
// mailSender.Body = "<p> Dear Sir/Madam, </p>";
// mailSender.Body += "<p><b>" + emp.Name + "</b>, Hiring Manager has completed the Candidate Selection process of Offer Letter for: " + ir.PositionName + " under " + dept.Name + " Department.</p>";
// mailSender.Body += "<p> Thank You" + "</p>";
// mailSender.SendMail(emailSettings);
// System.Threading.Thread.Sleep(500);
// }
//}
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpGet]
[Route("getPrevCvSort/{requisitionId}")]
public ActionResult GetPrevCvSort(int requisitionId)
{
List<CVSort> cvsorts = new List<CVSort>();
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
cvsorts = _cvService.GetCVSortByrequisitionID(requisitionId);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(cvsorts);
}
//private string GetContentType(string path)
//{
// var provider = new FileExtensionContentTypeProvider();
// string contentType;
// if (!provider.TryGetContentType(path, out contentType))
// {
// contentType = "application/octet-stream";
// }
// return contentType;
//}
[HttpGet]
[Route("getRecruitementSteps/{recruitementID}")]
public ActionResult getRecruitementSteps(int recruitementID)
{
List<RecruitementStep> obs = new List<RecruitementStep>();
try
{
obs = this._recruitementProcessService.GetRecruitementSteps(recruitementID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpGet]
[Route("GetRecruitementStepsWithSession/{recruitementID}")]
public ActionResult GetRecruitementStepsWithSession(int recruitementID)
{
List<RecruitementStep> obs = new List<RecruitementStep>();
try
{
obs = this._recruitementProcessService.GetRecruitementStepsWithSession(recruitementID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpGet]
[Route("getRecruitementStep/{stepid}")]
public ActionResult getRecruitementStep(int stepid)
{
RecruitementStep obs;
try
{
obs = this._recruitementProcessService.GetRStep(stepid);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpGet]
[Route("getRecruitementStepBySerial/{recruitementid}/{stepSerial}")]
public ActionResult getRecruitementStepBySerial(int recruitementid, int stepSerial)
{
RecruitementStep obs;
try
{
obs = this._recruitementProcessService.GetRStep(recruitementid, stepSerial);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpGet]
[Route("getSessionActiveCandidatesByStepID/{StepID}")]
public ActionResult getSessionActiveCandidatesByStepID(int StepID)
{
List<InterviewSessionCandidate> obs = new List<InterviewSessionCandidate>();
try
{
obs = this._recruitementProcessService.getSessionActiveCandidatesByStepID(StepID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpGet]
[Route("getInterviewSessions/{requsitionID}")]
public ActionResult getInterviewSessions(int requsitionID)
{
List<InterviewSession> obs = new List<InterviewSession>();
try
{
obs = this._recruitementProcessService.GetInterveiwSessions(requsitionID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
// Ess Function
[HttpGet]
[Route("getCurrentEmpInterviewSessions/{BoardMemberEntryStatus}")]
public ActionResult getCurrentEmpInterviewSessions(EnumBaordMemberMarkEntryStatus BoardMemberEntryStatus)
{
List<InterviewSession> obs = new List<InterviewSession>();
DataTable otable = null;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
otable = this._recruitementProcessService.GetInterveiwSessionsByBoardMember((int)currentUser.EmployeeID, BoardMemberEntryStatus);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(otable);
}
// void SaveMembersMarkByMemberID(InterviewSession session);
// List<InterviewSession> GetInterveiwSessionsByBoardMember(int employeeid, EnumBaordMemberMarkEntryStatus MarkEntrystatus);
[HttpPost]
[Route("CompleteMembersMarkByMember")]
public ActionResult CompleteMembersMarkByMember(InterviewSession item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
try
{
this._recruitementProcessService.CompleteMembersMarkByMember(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("SaveMembersMarkByMember")]
public ActionResult SaveMembersMarkByMember(InterviewSession item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
try
{
this._recruitementProcessService.SaveMembersMarkByMember(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpGet]
[Route("getInterviewSession/{interviewSessionID}")]
public ActionResult getInterviewSession(int interviewSessionID)
{
InterviewSession obs = null;
try
{
obs = this._recruitementProcessService.GetInterveiwSession(interviewSessionID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpGet]
[Route("GetmemberWiseMarkBySetpID/{StepID}")]
public ActionResult GetmemberWiseMarkBySetpID(int StepID)
{
List<MemberWiseMark> obs = null;
try
{
obs = this._recruitementProcessService.GetmemberWiseMarkBySetpID(StepID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpGet]
[Route("GetmemberWiseMarkBySessionID/{SessionID}")]
public ActionResult GetmemberWiseMarkBySessionID(int SessionID)
{
List<MemberWiseMark> obs = null;
try
{
obs = this._recruitementProcessService.GetmemberWiseMarkBySessionID(SessionID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpPost]
[Route("DeleteStep")]
public ActionResult DeleteStep(RecruitementStep item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
this._recruitementProcessService.DeleteStep(item.ID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("SaveRecruitementSteps")]
public ActionResult SaveRecruitementSteps(List<RecruitementStep> items)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
RecruitementProcess pr = this._recruitementProcessService.GetByRequisitionID(items[0].requisitionID);
if (pr == null)
{
pr = new RecruitementProcess();
pr.requisitionID = items[0].requisitionID;
pr.StartDate = items[0].StartDate;
pr.EndDate = items[items.Count - 1].EndDate;
pr.CreatedBy = currentUser.UserID;
pr.CreatedDate = DateTime.Today;
pr.ProcessStatus = EnumRecruitementProcess.None;
}
else
{
pr.requisitionID = items[0].requisitionID;
pr.ModifiedBy = currentUser.UserID;
pr.ModifiedDate = DateTime.Today;
}
pr.Steps = new List<RecruitementStep>();
pr.Steps.InsertRange(0, items);
try
{
this._recruitementProcessService.Save(pr);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(pr.Steps);
}
[HttpPost]
[Route("saveJoiningPreparation")]
public ActionResult saveJoiningPreparation(JoiningPreparation item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
try
{
new RecruitmentLettersService().SaveJoiningPreparation(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
[HttpPost]
[Route("SaveInterviewSession")]
public ActionResult SaveInterviewSession(InterviewSession item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
try
{
this._recruitementProcessService.SaveInterviewSession(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
[HttpPost]
[Route("SaveInterviewSessionWithKPI")]
public ActionResult SaveInterviewSessionWithKPI(dynamic data)
{
InterviewSession interveiwSession = new InterviewSession();
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
int? recruitementID = items["requisitionID"] == null ? null : (int)items["requisitionID"].ToObject<int>();
List<int> kpiIds = items["selectedKpiIds"] == null ? null : (List<int>)items["selectedKpiIds"].ToObject<List<int>>();
interveiwSession = items["interveiwSession"] == null ? null : (InterviewSession)items["interveiwSession"].ToObject<InterviewSession>();
interveiwSession.CreatedBy = currentUser.UserID;
interveiwSession.CreatedDate = DateTime.Today;
//save InterviewSession
this._recruitementProcessService.SaveInterviewSessionAndKPI(interveiwSession, kpiIds, (int)recruitementID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("saveInsertInterviewAssessmentBySessionAndKPI")]
public ActionResult SaveInsertInterviewAssessmentBySessionAndKPI(dynamic data)
{
try
{
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(true);
}
[HttpPost]
[Route("SendInteviewSessionMail")]
public ActionResult SendInteviewSessionMail(InterviewSession item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
try
{
this._recruitementProcessService.SendMailInThread(item);
this._recruitementProcessService.UpdateInterviewStartDate(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("DeleteUserCvSort")]
public ActionResult DeleteUserCvSort(UserCvSort item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
_cvService.DeleteUserCvsort(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("CancelInteviewSession")]
public ActionResult CancelInteviewSession(InterviewSession item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
try
{
this._recruitementProcessService.CancelInterViewSession(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("RescheduleInteviewSession")]
public ActionResult RescheduleInteviewSession(InterviewSession item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
try
{
this._recruitementProcessService.RescheduleInterViewSession(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("SaveMemberWiseMark")]
public ActionResult SaveMemberWiseMark(InterviewSession session)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
foreach (InterviewSessionCandidate item in session.Candidates)
{
if (item.IsNew == true)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
}
foreach (MemberWiseMark item in session.BoadMemberWiseMarks)
{
if (item.IsNew == true)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
}
try
{
this._recruitementProcessService.SaveMemberWiseMark(session);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("CompleteSessionStatus")]
public ActionResult CompleteSessionStatus(InterviewSession item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
this._recruitementProcessService.CompleteInterviewSession(item);
//updateJobUpdateErecruitment(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
public void updateJobUpdateErecruitment(InterviewSession item)
{
List<ErAppliedApplicant> appliedApplicnt = new List<ErAppliedApplicant>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
RecruitementStep currentStep;
try
{
currentStep = new RecruitementStep();
currentStep = this._recruitementProcessService.GetRStep(item.requitementStepID);
appliedApplicnt = _erAppliedApplicantService.GetApplicantInfoByRecruitmentID(currentStep.requisitionID).ToList();
if (currentStep != null)
{
foreach (var tempItem in item.Candidates)
{
ErJobupdate jobUpdate = new ErJobupdate();
CV cv = new CV();
cv = _cvService.Get(tempItem.cvid);
ErCV ercv = new ErCV();
ercv = _ercvService.Get((int)cv.ErCvID);
jobUpdate.UserID = ercv.UserID;
jobUpdate.JobID = appliedApplicnt.Where(x => x.UserID == ercv.UserID).FirstOrDefault().JobID;
jobUpdate.Remarks = tempItem.isSelected ? "On " + item.interviewDate.ToString("dd MMMM yyyy") + ", You have selected for " + currentStep.getStepName() :
"On " + item.interviewDate.ToString("dd MMMM yyyy") + ", You have not selected for " + currentStep.getStepName();
jobUpdate.UpdateDate = DateTime.Now;
jobUpdate.UpdatedBy = EnumActorType.Admin;
jobUpdate.AppliedApplicantID = appliedApplicnt.Where(x => x.UserID == ercv.UserID).FirstOrDefault().ID;
_erAppliedApplicantService.Save(jobUpdate);
}
}
}
catch (Exception ex)
{
StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
}
[HttpPost]
[Route("CompleteRecruitementStep")]
public ActionResult CompleteRecruitementStep(RecruitementStep item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
this._recruitementProcessService.CompleteRecruitementStep(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("SaveRecruitementLetters")]
public ActionResult SaveRecruitementLetters(List<RecruitmentLetters> items)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
foreach (RecruitmentLetters item in items)
{
item.CreatedDate = DateTime.Today;
item.CreatedBy = currentUser.UserID;
}
try
{
this._recruitementLettterService.Save(items);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpGet]
[Route("GetRecruitementLetters/{requisitionID}")]
public ActionResult GetRecruitementLetters(int requisitionID)
{
List<RecruitmentLetters> obs = null;
try
{
obs = this._recruitementLettterService.GetbyRequisitionID(requisitionID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpGet("getBudgetHeadCount/{departmentId}/{designationId}/{positionDate}")]
public ActionResult GetCurrentHeadCount(int departmentId, int designationId, DateTime positionDate)
{
int empCount = 0;
try
{
empCount = _headCountApprovalRequestService.GetBudgetedHeadCount(departmentId, designationId,
positionDate);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(empCount);
}
[HttpGet("getBudgetHeadCountByRequisitionID/{positionDate}")]
public ActionResult GetBudgetedHeadCountByrequisitionID(DateTime positionDate)
{
List<HeadCountApprovalRequest> obs = new List<HeadCountApprovalRequest>();
try
{
obs = _headCountApprovalRequestService.GetBudgetedHeadCountByrequisitionID(positionDate);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
#region Assign Candidate
[HttpGet]
[Route("getCandidateByProcessid/{pId}")]
public ActionResult getCandidateByProcessid(int pID)
{
List<Candidate> obs = new List<Candidate>();
try
{
obs = _candidateService.GetCanditates(pID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpPost]
[Route("saveCandidates")]
public ActionResult saveCandidates(List<Candidate> items)
{
try
{
string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
_candidateService.Save(items, connectionString);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveCandidatesforRecruitment")]
public ActionResult saveCandidatesforRecruitment(List<Candidate> items)
{
try
{
// string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
_candidateService.SaveCandidateAnDUpdateCV(items);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("updateCVOnInitiateDone")]
public ActionResult UpdateCVOnInitiateDone(List<Candidate> items)
{
try
{
// string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
_candidateService.UpdateCVOnInitiateDone(items);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("saveUserCVSort")]
public ActionResult saveUserCVSort(UserCvSort item)
{
try
{
var isNew = item.ID <= 0;
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (isNew)
{
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
}
// string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
_cvService.SaveUserCVSort(item);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpGet]
[Route("updatePrimarySelection")]
public ActionResult updatePrimarySelection(int candidateId)
{
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
// string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
_candidateService.UpdatePrimarySelection(candidateId, true, (int)currentUser.EmployeeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpGet]
[Route("getJoiningPreparationByRecruitmentLetterID/{rID}")]
public ActionResult getJoiningPreparationByRecruitmentLetterID(int rID)
{
List<JoiningPreparation> jp = new List<JoiningPreparation>();
try
{
jp = new RecruitmentLettersService().GetJoiningPreparationbyRecruitmentLetterID(rID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(jp);
}
[HttpGet]
[Route("getFilesByCVId/{cId}")]
public ActionResult getFilesByCVId(int cId)
{
List<FileAttachment> obs = new List<FileAttachment>();
try
{
obs = _cvService.GetCVAttachmentbyID(cId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
[HttpGet]
[Route("dtGetRecruitmentbyCVSort")]
public ActionResult dtGetRecruitmentbyCVSort()
{
Employee ohrEmp = null;
List<RecruitmentByCVSort> sortItems = new List<RecruitmentByCVSort>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (currentUser.EmployeeID == null)
{
return StatusCode(StatusCodes.Status500InternalServerError, "Employee Not Found");
}
// DataTable oCV = new DataTable();
try
{
sortItems = _cvService.dtGetRecruitmentbyCVSort((int)currentUser.EmployeeID);
//foreach(DataRow item in oCV.Rows)
//{
// int recid = Convert.ToInt32(item["cvSortID"].ToString());
// int recid = item["cvSortID"] is DBNull ? 0 : Convert.ToInt32(item["cvSortID"].ToString());
//}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(sortItems);
}
[HttpGet]
[Route("dtGetRecruitmentForCandidateSelectionOfferLetter")]
public ActionResult dtGetRecruitmentForCandidateSelectionOfferLetter()
{
Employee ohrEmp = null;
List<InternalRecruitment> ir = new List<InternalRecruitment>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (currentUser.EmployeeID == null)
{
return StatusCode(StatusCodes.Status500InternalServerError, "Employee Not Found");
}
try
{
ir = _internalRecruitmentService.GetRecruitmentForCandidateSelectionOfferLetter((int)currentUser.EmployeeID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(ir);
}
[HttpGet]
[Route("dtCVSortDetails/{positionID}")]
public ActionResult dtCVSortDetails(int positionID)
{
Employee ohrEmp = null;
List<CVSortDetails> sortItems = new List<CVSortDetails>();
try
{
sortItems = _cvService.dtCVSortDetails(positionID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(sortItems);
}
[HttpGet]
[Route("getPreciousCV/{positionId}")]
public ActionResult GetPreciousCV(int positionId)
{
List<CV> allCVs = new List<CV>();
try
{
allCVs = _cvService.GetPreviousCVbyRequisitionID(positionId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(allCVs);
}
[HttpGet]
[Route("getCandidateCV/{candidateId}")]
public ActionResult GetCandidateCV(int candidateId)
{
List<CV> allCVs = new List<CV>();
try
{
allCVs = _cvService.GetPreviousCVbyRequisitionID(candidateId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(allCVs);
}
[HttpGet]
[Route("IsRequisitionComplete/{positionId}")]
public ActionResult IsRequisitionComplete(int positionId)
{
bool isComplete;
try
{
isComplete = _cvService.IsRequisitionComplete(positionId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(isComplete);
}
[HttpGet]
[Route("updateCompleteStatus/{positionId}")]
public ActionResult UpdateCompleteStatus(int positionId)
{
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
if (currentUser.EmployeeID == null)
{
return StatusCode(StatusCodes.Status500InternalServerError, "Employee Not Found");
}
_cvService.UpdateCompleteStatus(positionId, (int)currentUser.EmployeeID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpGet]
[Route("updateReqCompleteStatus/{positionId}")]
public ActionResult UpdateReqCompleteStatus(int positionId)
{
try
{
_internalRecruitmentService.UpdateCompleteStatus(positionId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpGet]
[Route("getEmployeesRequisitionID/{requisitionID}")]
public ActionResult getEmployeesRequisitionID(int requisitionID)
{
List<Employee> obs = new List<Employee>();
try
{
obs = _employeeService.GetEmployeesRequisitionID(requisitionID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(obs);
}
#endregion
[HttpPost]
[Route("saveRecruitmentPublish")]
public ActionResult SaveRecruitmentPublish(ErCircular item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
item.ModifiedBy = currentUser.UserID;
item.ModifiedDate = DateTime.Today;
try
{
_erCircularService.Save(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpGet]
[Route("getJobDetailsbyRecruitmentID/{recruitmentId}")]
public ActionResult getJobDetailsbyRecruitmentID(int recruitmentId)
{
List<ErAppliedApplicant> appliedApplicants = new List<ErAppliedApplicant>();
try
{
appliedApplicants = _erAppliedApplicantService.GetApplicantInfoByRecruitmentID(recruitmentId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(appliedApplicants);
}
[HttpGet]
[Route("getErCvByUserId/{userId}/{recruitmentId}")]
public ActionResult getErCvByUserId(int userId, int recruitmentId)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
ErCV ercv = null;
CV cv = null;
try
{
ercv = _ercvService.GetErCvByUserID(userId);
var isCvAlreadyCreated = _cvService.GetByCvSearch(null, ercv.Email, null);
if (ercv != null && (isCvAlreadyCreated == null || isCvAlreadyCreated.Count == 0))
{
cv = new CV();
cv.FirstName = ercv.FirstName;
cv.LastName = ercv.LastName;
cv.Name = ercv.FirstName + " " + ercv.LastName;
cv.Email = ercv.Email;
cv.Mobile = ercv.Mobile;
cv.Designation = ercv.Designation;
cv.PresentAddress = ercv.PresentAddress;
cv.PermanentAddress = ercv.PermanentAddress;
cv.Gender = ercv.Gender;
cv.MaritalStatus = ercv.MaritalStatus;
cv.ReligionID = ercv.ReligionID;
cv.SortStatus = ercv.SortStatus;
cv.ErCvID = ercv.ID;
cv.CreatedBy = currentUser.UserID;
cv.CreatedDate = DateTime.Now;
cv.PositionID = recruitmentId;
if (ercv.AllExperiences != null && ercv.AllExperiences.Count > 0)
{
cv.AllExperiences = new List<CVExperience>();
foreach (var item in ercv.AllExperiences)
{
var experience = new CVExperience();
experience.Employeer = item.Employeer;
experience.ContactPerson = item.ContactPerson;
experience.Address = item.Address;
experience.Industry = item.Industry;
experience.FromDate = item.FromDate;
experience.ToDate = item.ToDate;
experience.Telephone = item.Telephone;
experience.RoleDefination = item.RoleDefination;
cv.AllExperiences.Add(experience);
}
}
if (ercv.AllEduQualifications != null && ercv.AllEduQualifications.Count > 0)
{
cv.AllEduQualifications = new List<CVEducation>();
foreach (var item in ercv.AllEduQualifications)
{
var education = new CVEducation();
education.DegreeTitleID = item.DegreeTitleID;
education.DegreeTitle = item.DegreeTitle;
education.DisciplineID = item.DisciplineID;
education.BoardID = item.BoardID;
education.Boar = item.Boar;
education.Name = item.Name;
education.PassingYear = item.PassingYear;
education.ResultID = item.ResultID;
education.CGPA = item.CGPA;
education.OutOF = item.OutOF;
education.IsHighest = item.IsHighest;
education.InstituteName = item.InstituteName;
cv.AllEduQualifications.Add(education);
}
}
if (ercv.CVReferences != null && ercv.CVReferences.Count > 0)
{
cv.CVReferences = new List<CVReference>();
foreach (var item in ercv.CVReferences)
{
var reference = new CVReference();
reference.Name = item.Name;
reference.Occupation = item.Occupation;
reference.Relation = item.Relation;
reference.Address = item.Address;
reference.Email = item.Email;
reference.Telephone = item.Telephone;
reference.Mobile = item.Mobile;
cv.CVReferences.Add(reference);
}
}
if (ercv.CVTrainings != null && ercv.CVTrainings.Count > 0)
{
cv.CVTrainings = new List<CVTraining>();
foreach (var item in ercv.CVTrainings)
{
var training = new CVTraining();
training.Name = item.Name;
training.Description = item.Description;
training.Country = item.Country;
training.TrainingTypeID = item.TrainingTypeID;
training.NatureOfTrainingID = item.NatureOfTrainingID;
training.TrainingCompletedFrom = item.TrainingCompletedFrom;
training.InstitutionID = item.InstitutionID;
training.Place = item.Place;
training.Achievement = item.Achievement;
training.Fees = item.Fees;
training.OtherCost = item.OtherCost;
training.FromDate = item.FromDate;
training.ToDate = item.ToDate;
cv.CVTrainings.Add(training);
}
}
if (ercv.ErCVProfilePhoto != null)
{
cv.CVProfilePhoto = ercv.ErCVProfilePhoto;
cv.CVProfilePhoto.FileType = EnumFileType.CVProfilePhoto;
}
if (ercv.IRFileAttacments != null && ercv.IRFileAttacments.Count > 0)
{
cv.IRFileAttacments = new List<FileAttachment>();
foreach (var item in ercv.IRFileAttacments)
{
item.FileType = EnumFileType.CV;
cv.IRFileAttacments.Add(item);
}
}
}
else
{
throw new Exception("cv bank has been already created");
}
if (cv != null)
{
string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
_cvService.Save(cv, connectionString);
}
else
{
throw new Exception("cv bank not saved");
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpPost]
[Route("createcvbankandcandidate")]
public ActionResult createCvbankandCandidate(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<ErCV> oCVs = new List<ErCV>();
List<CV> _cvs = new List<CV>();
List<EducationLevel> educationLevels = new List<EducationLevel>();
educationLevels = _educationLevelService.Get(EnumStatus.Active);
List<Discipline> disciplines = new List<Discipline>();
disciplines = _disciplineService.Get(EnumStatus.Active);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
int recruitmentId = items["recruitmentId"] == null ? 0 : items["recruitmentId"].ToObject<int>();
string cvids = items["cvIds"] == null ? 0 : items["cvIds"].ToObject<string>();
try
{
if (!string.IsNullOrEmpty(cvids))
{
oCVs = _ercvService.GetErCvByCvids(cvids);
foreach (var ercv in oCVs)
{
var isCvAlreadyCreated = _cvService.GetByCvSearch(null, ercv.Email, ercv.Mobile);
CV cv = null;
if (ercv != null && (isCvAlreadyCreated == null || isCvAlreadyCreated.Count == 0))
{
cv = new CV();
cv.FirstName = ercv.FirstName;
cv.LastName = ercv.LastName;
cv.Name = ercv.FirstName + " " + ercv.LastName;
cv.Email = ercv.Email;
cv.Mobile = ercv.Mobile;
cv.Designation = ercv.Designation;
cv.PresentAddress = ercv.PresentAddress;
cv.PermanentAddress = ercv.PermanentAddress;
cv.Gender = ercv.Gender;
cv.MaritalStatus = ercv.MaritalStatus;
cv.ReligionID = ercv.ReligionID;
cv.SortStatus = ercv.SortStatus;
cv.ErCvID = ercv.ID;
cv.CreatedBy = currentUser.UserID;
cv.CreatedDate = DateTime.Now;
cv.PositionID = recruitmentId;
string experienceSummary = "";
if (ercv.AllExperiences != null && ercv.AllExperiences.Count > 0)
{
cv.AllExperiences = new List<CVExperience>();
foreach (var item in ercv.AllExperiences)
{
var experience = new CVExperience();
experience.Employeer = item.Employeer;
experience.ContactPerson = item.ContactPerson;
experience.Address = item.Address;
experience.Industry = item.Industry;
experience.FromDate = item.FromDate;
experience.ToDate = item.ToDate;
experience.Telephone = item.Telephone;
experience.RoleDefination = item.RoleDefination;
cv.AllExperiences.Add(experience);
var diffDays = (item.ToDate - item.FromDate).TotalDays;
experienceSummary += "Total Experince: " + diffDays + "\n"
+ "Company: " + item.Industry + "\n"
+ "Position: " + item.Designation + "\n"
+ "Role: " + item.RoleDefination + "\n";
}
cv.Experience = experienceSummary;
}
string educationSummary = "";
if (ercv.AllEduQualifications != null && ercv.AllEduQualifications.Count > 0)
{
cv.AllEduQualifications = new List<CVEducation>();
foreach (var item in ercv.AllEduQualifications)
{
var education = new CVEducation();
education.DegreeTitleID = item.DegreeTitleID;
education.DegreeTitle = item.DegreeTitle;
education.DisciplineID = item.DisciplineID;
education.BoardID = item.BoardID;
education.Boar = item.Boar;
education.Name = item.Name;
education.PassingYear = item.PassingYear;
education.ResultID = item.ResultID;
education.CGPA = item.CGPA;
education.OutOF = item.OutOF;
education.IsHighest = item.IsHighest;
education.InstituteName = item.InstituteName;
cv.AllEduQualifications.Add(education);
if (item.DegreeTitleID > 0)
{
educationSummary += "Degree Title: " + educationLevels?.Find(c => c.ID == item.DegreeTitleID)?.Description + "\n"
+ "Department: " + disciplines?.Find(c => c.ID == item.DisciplineID)?.Description + "\n"
+ "Institute: " + item.InstituteName + "\n"
+ "Passing Year: " + item.PassingYear + "\n"
+ "CGPA: " + item.CGPA + "\n";
}
}
cv.Education = educationSummary;
}
string references = "";
if (ercv.CVReferences != null && ercv.CVReferences.Count > 0)
{
cv.CVReferences = new List<CVReference>();
foreach (var item in ercv.CVReferences)
{
var reference = new CVReference();
reference.Name = item.Name;
reference.Occupation = item.Occupation;
reference.Relation = item.Relation;
reference.Address = item.Address;
reference.Email = item.Email;
reference.Telephone = item.Telephone;
reference.Mobile = item.Mobile;
cv.CVReferences.Add(reference);
references += "Name: " + item.Name + "\n"
+ "Occupation: " + item.Occupation + "\n"
+ "Relation: " + item.Relation + "\n"
+ "Address: " + item.Address + "\n"
+ "Mobile: " + item.Mobile + "\n";
}
cv.Reference = references;
}
if (ercv.CVTrainings != null && ercv.CVTrainings.Count > 0)
{
cv.CVTrainings = new List<CVTraining>();
foreach (var item in ercv.CVTrainings)
{
var training = new CVTraining();
training.Name = item.Name;
training.Description = item.Description;
training.Country = item.Country;
training.TrainingTypeID = item.TrainingTypeID;
training.NatureOfTrainingID = item.NatureOfTrainingID;
training.TrainingCompletedFrom = item.TrainingCompletedFrom;
training.InstitutionID = item.InstitutionID;
training.Place = item.Place;
training.Achievement = item.Achievement;
training.Fees = item.Fees;
training.OtherCost = item.OtherCost;
training.FromDate = item.FromDate;
training.ToDate = item.ToDate;
cv.CVTrainings.Add(training);
}
}
if (ercv.ErCVProfilePhoto != null)
{
cv.CVProfilePhoto = ercv.ErCVProfilePhoto;
cv.CVProfilePhoto.FileType = EnumFileType.CVProfilePhoto;
}
if (ercv.IRFileAttacments != null && ercv.IRFileAttacments.Count > 0)
{
cv.IRFileAttacments = new List<FileAttachment>();
foreach (var item in ercv.IRFileAttacments)
{
item.FileType = EnumFileType.CV;
cv.IRFileAttacments.Add(item);
}
}
_cvs.Add(cv);
}
else
{
throw new Exception("cv bank has been already created");
}
}
if (_cvs != null)
{
string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
_cvService.SaveCVs(_cvs);
}
else
{
throw new Exception("cv bank not saved");
}
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(oCVs);
}
[HttpGet]
[Route("getErCvByRequisitionId/{recruitmentId}")]
public ActionResult GetErCvByRequisitionId(int recruitmentId)
{
List<ErCV> appliedApplicants = new List<ErCV>();
try
{
appliedApplicants = _ercvService.GetErCvByRequisitionId(recruitmentId);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(appliedApplicants);
}
//[HttpGet]
//[Route("UpdateCvNameMobileEmail/{cvId}/{name}/{mobile}/{email}/{reference}/{education}/{experience}/{skill}")]
//public ActionResult UpdateCvNameMobileEmail(int cvId, string name, string mobile, string email, string reference, string education, string experience, string skill)
//{
// name = (name == "undefined" || name == "null") ? string.Empty : name;
// email = (email == "undefined" || email == "null") ? string.Empty : email;
// mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile;
// reference = (reference == "undefined" || reference == "null") ? string.Empty : reference;
// education = (education == "undefined" || education == "null") ? string.Empty : education;
// experience = (experience == "undefined" || experience == "null") ? string.Empty : experience;
// skill = (skill == "undefined" || skill == "null") ? string.Empty : skill;
// try
// {
// _cvService.UpdateCvNameMobileEmail(cvId, name, mobile, email, reference, education, experience, skill);
// }
// catch (Exception ex)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
// }
// return Ok();
//}
[HttpGet]
[Route("EmailAndPhoneDuplicateCheck/{mobile}/{email}")]
public ActionResult EmailAndPhoneDuplicateCheck(string mobile, string email)
{
List<CV> cvList = new List<CV>();
email = (email == "undefined" || email == "null") ? string.Empty : email;
mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile;
bool isDuplicate = false;
try
{
cvList = _cvService.EmailAndPhoneDuplicateCheck(mobile, email);
if (cvList != null && cvList.Count > 0)
{
isDuplicate = true;
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(isDuplicate);
}
[Route("getPrevErCircular/{recruitmentID}")]
public ActionResult GetPrevErCircular(int recruitmentID)
{
ErCircular erCircular = null;
try
{
erCircular = _erCircularService.GetByRequisition(recruitmentID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(erCircular);
}
[Route("getErCircularList")]
public ActionResult GeAErCircular()
{
List<ErCircular> erCircularList = new List<ErCircular>();
try
{
erCircularList = _erCircularService.GetAll();
if (erCircularList != null && erCircularList.Count > 0)
{
foreach (var item in erCircularList)
{
if (item.RecruitmentDate != null && item.RecruitmentDate == DateTime.MinValue)
{
item.RecruitmentDate = null;
}
}
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(erCircularList);
}
2026-11-04 19:03:36 +06:00
//[HttpPost("uploadFile")]
//[AllowAnonymous]
//public ActionResult uploadFile()
//{
// string base64String = "";
// try
// {
// //var files = Request.Form.Files;
// //foreach (var formFile in files)
// //{
// // var fileSize = formFile.Length;
// // var originalFile = formFile.FileName;
// // var fileExt = System.IO.Path.GetExtension(originalFile).Substring(1);
// // var fileName = _filePath + formFile.FileName;
// // var ms = new MemoryStream();
// // formFile.CopyTo(ms);
// // byte[] textAsBytes = ms.ToArray();
// // base64String = Convert.ToBase64String(textAsBytes);
// // using (PdfReader pdfReader = new PdfReader(ms))
// // {
// // for (int page = 1; page <= pdfReader.NumberOfPages; page++)
// // {
// // ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
// // string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);
// // currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText)));
// // text.Append(currentText);
// // }
// // }
// //}
2026-11-03 13:06:00 +06:00
2026-11-04 19:03:36 +06:00
// }
// catch (Exception ex)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
// }
2026-11-03 13:06:00 +06:00
2026-11-04 19:03:36 +06:00
// return Ok(base64String);
//}
2026-11-03 13:06:00 +06:00
[HttpPost("readPDf")]
[AllowAnonymous]
public ActionResult readPDF()
{
var remoteIpAddress = HttpContext.Connection.RemoteIpAddress;
List<CvReaderAndExtractor> cvList = new List<CvReaderAndExtractor>();
List<CV> allCVs = new List<CV>();
var results = new List<CV>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var requisitionId = Convert.ToInt32(Request.Form["requisitionId"]);
try
{
cvList = new CVParserService().readPDF(Request.Form.Files);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
try
{
foreach (var cv in cvList)
{
string mobileNo = null;
if (cv.MobileNumber != null)
mobileNo = cv.MobileNumber = cv.MobileNumber.Replace("+88", "");
List<CV> existingCvList = new List<CV>();
CV newCv = new CV();
//if(mobileNo !="") existingCvList = _cvService.EmailAndPhoneDuplicateCheck(mobileNo, null);
if (mobileNo != null) existingCvList = _cvService.EmailAndPhoneDuplicateCheck(mobileNo, null);
cv.IsExisting = "New";
if (existingCvList != null && existingCvList.Count > 0)
{
cv.IsExisting = "Already Exist";
var eItem = existingCvList.FirstOrDefault();
newCv.ID = eItem.ID;
newCv.Mobile = eItem.Mobile;
newCv.Name = cv.Name == "" ? eItem.Name : cv.Name;
newCv.Email = cv.Email == "" ? eItem.Email : cv.Email;
}
else
{
newCv.Name = cv.Name == "" ? null : cv.Name;
newCv.Mobile = cv.MobileNumber == "" ? null : cv.MobileNumber;
newCv.Email = cv.Email == "" ? null : cv.Email;
newCv.CreatedBy = 1;
newCv.CreatedDate = DateTime.Today;
}
newCv.SerialId = cv.SerialId;
cv.isValidCV = newCv.IsValidCv;
if (newCv.IsValidCv)
newCv.PositionID = requisitionId;
newCv.Education = cv.Education;
newCv.Experience = cv.Experience;
newCv.Skill = cv.Skill;
newCv.IRFileAttacments = new List<FileAttachment>();
FileAttachment fileAttachment = new FileAttachment();
fileAttachment.OriginalFileName = cv.FileName;
fileAttachment.FileType = EnumFileType.CV;
fileAttachment.isCvExtractorModule = true;
fileAttachment.FileAsByteArray = cv.FileAsByteArray;
fileAttachment.Extension = cv.Ext;
if (cv.ProfilePicByteArray != null)
{
FileAttachment dp = new FileAttachment();
dp.OriginalFileName = cv.FileName;
dp.FileType = EnumFileType.CVProfilePhoto;
dp.FileAsByteArray = cv.ProfilePicByteArray;
dp.isCvExtractorModule = true;
dp.Extension = cv.Ext;
newCv.IRFileAttacments.Add(dp);
}
newCv.IRFileAttacments.Add(fileAttachment);
allCVs.Add(newCv);
}
results = _cvService.SaveCVs(allCVs);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
if (results.Count == cvList.Count)
{
for (int i = 0; i < cvList.Count; i++)
{
cvList[i].CVId = results[i].ID;
}
}
return Ok(cvList);
}
//public ActionResult readPDF()
//{
// var remoteIpAddress = HttpContext.Connection.RemoteIpAddress;
// string base64String = "";
// List<CvReaderAndExtractor> cvList = new List<CvReaderAndExtractor>();
// List<CV> allCVs = new List<CV>();
// var results = new List<CV>();
// CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
// try
// {
// const string MatchEmailPattern =
// @"(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
// + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
// + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
// + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})";
// var files = Request.Form.Files;
// var requisitionId = Convert.ToInt32(Request.Form["requisitionId"]);
// int serial = 0;
// foreach (var formFile in files)
// {
// byte[] profilePictures = null;
// StringBuilder text = new StringBuilder();
// serial++;
// var fileSize = formFile.Length;
// var originalFile = formFile.FileName;
// var fileExt = System.IO.Path.GetExtension(originalFile).Substring(1);
// var fileName = _filePath + formFile.FileName;
// var ms = new MemoryStream();
// formFile.CopyTo(ms);
// byte[] textAsBytes = ms.ToArray();
// string fileType = null;
// base64String = Convert.ToBase64String(textAsBytes);
// using (PdfReader pdfReader = new PdfReader(textAsBytes))
// {
// for (int page = 1; page <= pdfReader.NumberOfPages; page++)
// {
// ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
// string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);
// currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText)));
// text.Append(currentText);
// }
// }
// using (MemoryStream pdfStream = new MemoryStream(textAsBytes)) // assuming pdfBytes is your byte array containing the PDF document
// {
// using (UglyToad.PdfPig.PdfDocument pdfDocument = UglyToad.PdfPig.PdfDocument.Open(pdfStream))
// {
// int imageCount = 1;
// foreach (Page page in pdfDocument.GetPages())
// {
// List<XObjectImage> images = page.GetImages().Cast<XObjectImage>().ToList();
// foreach (XObjectImage image in images)
// {
// byte[] imageRawBytes = image.RawBytes.ToArray();
// if (imageRawBytes != null)
// {
// profilePictures = imageRawBytes;
// fileType = GetFileType(imageRawBytes);
// break;
// }
// //using (FileStream stream = new FileStream($"{_filePath}\\{imageCount}.png", FileMode.Create, FileAccess.Write))
// //using (BinaryWriter writer = new BinaryWriter(stream))
// //{
// // writer.Write(imageRawBytes);
// // writer.Flush();
// //}
// imageCount++;
// }
// if (imageCount > 0)
// {
// break;
// }
// }
// }
// }
// var text1 = text.ToString();
// string[] wordList = text1.Split(' ');
// string tempPhoneNumber = null;
// string tempEmail = null;
// string numericPart = null;
// }
// }
// numericPart = "+" + numericPart;
// }
// else
// {
// if ((wordList[i].Where(char.IsDigit).ToArray().Length) > 13)
// {
// int endIndex = Math.Min(13, wordList[i].Length);
// numericPart = string.Join(" ", wordList[i], 0, endIndex);
// }
// numericPart = "+" + numericPart;
// }
//}
//isNumber = true;
// }
// }
// }
// numericPart = "+" + numericPart;
// }
// else
// {
// if ((wordList[i].Where(char.IsDigit).ToArray().Length) > 13)
// {
// int endIndex = Math.Min(13, wordList[i].Length);
// numericPart = string.Join(" ", wordList[i], 0, endIndex);
// }
// numericPart = "+" + numericPart;
// }
// }
// isNumber = true;
// // }
// }
// if (isNumber)
// {
// const string MatchPhonePattern = @"\b(\+?8801\d{9}|01\d{9})\b";
// Regex rx = new Regex(MatchPhonePattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
// MatchCollection matches = rx.Matches(numericPart);
// int noOfMatches = matches.Count;
// foreach (Match match in matches)
// {
// tempPhoneNumber = match.Value.ToString();
// }
// if (tempPhoneNumber != null)
// {
// if (numericPart.Contains("+") && !tempPhoneNumber.Contains("+"))
// {
// tempPhoneNumber = "+" + tempPhoneNumber;
// }
// }
// }
// }
// }
// // email address
// if (wordList[i].Contains('@') && string.IsNullOrEmpty(tempEmail))
// {
// Regex rx = new Regex(
// MatchEmailPattern,
// RegexOptions.Compiled | RegexOptions.IgnoreCase);
// MatchCollection matches = rx.Matches(wordList[i]);
// int noOfMatches = matches.Count;
// foreach (Match match in matches)
// {
// tempEmail = match.Value.ToString();
// }
// }
// }
// var name = extractNames(wordList);
// var education = extractEducation(wordList);
// var experience = extractExperience(wordList);
// var skill = extractSkills(text1);
// // extractEducation(wordList);
// CvReaderAndExtractor cv = new CvReaderAndExtractor();
// cv.SerialId = serial;
// cv.Name = (name == null || name == string.Empty) ? System.IO.Path.GetFileNameWithoutExtension(originalFile) : name;
// cv.Email = tempEmail;
// cv.MobileNumber = tempPhoneNumber;
// cv.FileName = originalFile;
// cv.FileAsByteArray = textAsBytes;
// cv.ProfilePicByteArray = profilePictures;
// cv.Ext = fileType;
// cv.Education = education;
// cv.Experience = experience;
// cv.Skill = skill;
// cv.Ext = fileExt;
// cvList.Add(cv);
// }
// if (cvList.Count > 0)
// {
// foreach (var cv in cvList)
// {
// string mobileNo = null;
// if (cv.MobileNumber != null)
// mobileNo = cv.MobileNumber = cv.MobileNumber.Replace("+88", "");
// List<CV> existingCvList = new List<CV>();
// if (!string.IsNullOrEmpty(mobileNo))
// {
// existingCvList = _cvService.EmailAndPhoneDuplicateCheck(mobileNo, null);
// if (existingCvList != null && existingCvList.Count > 0)
// {
// cv.IsExisting = "Already Exist";
// var existingCv = existingCvList.FirstOrDefault();
// if (existingCv != null)
// {
// if (cv.Name != null)
// {
// if (!string.IsNullOrEmpty(cv.Name))
// {
// existingCv.Name = cv.Name;
// string[] separated = cv.Name.Split(' ');
// if (separated.Length == 3)
// {
// existingCv.FirstName = separated[0] + " " + separated[1];
// existingCv.LastName = separated[2];
// }
// else if (separated.Length == 2)
// {
// existingCv.FirstName = separated[0];
// existingCv.LastName = separated[1];
// }
// else
// {
// existingCv.FirstName = cv.Name;
// }
// }
// }
// else
// {
// existingCv.FirstName = null;
// existingCv.LastName = null;
// }
// existingCv.Mobile = cv.MobileNumber;
// existingCv.Email = cv.Email;
// existingCv.ModifiedBy = -9;
// existingCv.ModifiedDate = DateTime.Today;
// existingCv.SerialId = cv.SerialId;
// existingCv.PositionID = requisitionId;
// existingCv.Education = cv.Education;
// existingCv.Experience = cv.Experience;
// existingCv.Skill = cv.Skill;
// existingCv.IRFileAttacments = new List<FileAttachment>();
// FileAttachment fileAttachment = new FileAttachment();
// fileAttachment.OriginalFileName = cv.FileName;
// fileAttachment.FileType = EnumFileType.CV;
// fileAttachment.FileAsByteArray = cv.FileAsByteArray;
// fileAttachment.isCvExtractorModule = true;
// fileAttachment.Extension = cv.Ext;
// if (cv.ProfilePicByteArray != null)
// {
// FileAttachment dp = new FileAttachment();
// dp.OriginalFileName = cv.FileName;
// dp.FileType = EnumFileType.CVProfilePhoto;
// dp.FileAsByteArray = cv.ProfilePicByteArray;
// dp.isCvExtractorModule = true;
// dp.Extension = cv.Ext;
// existingCv.IRFileAttacments.Add(dp);
// }
// existingCv.IRFileAttacments.Add(fileAttachment);
// allCVs.Add(existingCv);
// }
// }
// else
// {
// cv.IsExisting = "New";
// CV newCv = new CV();
// if (cv.Name != null)
// {
// newCv.Name = cv.Name;
// string[] separated = cv.Name.Split(' ');
// if (separated.Length == 3)
// {
// newCv.FirstName = separated[0] + " " + separated[1];
// newCv.LastName = separated[2];
// }
// else if (separated.Length == 2)
// {
// newCv.FirstName = separated[0];
// newCv.LastName = separated[1];
// }
// else
// {
// newCv.FirstName = cv.Name;
// }
// }
// else
// {
// newCv.FirstName = null;
// newCv.LastName = null;
// }
// newCv.Mobile = cv.MobileNumber;
// newCv.Email = cv.Email;
// newCv.CreatedBy = -9;
// newCv.CreatedDate = DateTime.Today;
// newCv.SerialId = cv.SerialId;
// newCv.PositionID = requisitionId;
// newCv.Education = cv.Education;
// newCv.Experience = cv.Experience;
// newCv.Skill = cv.Skill;
// newCv.IRFileAttacments = new List<FileAttachment>();
// FileAttachment fileAttachment = new FileAttachment();
// fileAttachment.OriginalFileName = cv.FileName;
// fileAttachment.FileType = EnumFileType.CV;
// fileAttachment.isCvExtractorModule = true;
// fileAttachment.FileAsByteArray = cv.FileAsByteArray;
// fileAttachment.Extension = cv.Ext;
// if (cv.ProfilePicByteArray != null)
// {
// FileAttachment dp = new FileAttachment();
// dp.OriginalFileName = cv.FileName;
// dp.FileType = EnumFileType.CVProfilePhoto;
// dp.FileAsByteArray = cv.ProfilePicByteArray;
// dp.isCvExtractorModule = true;
// dp.Extension = cv.Ext;
// newCv.IRFileAttacments.Add(dp);
// }
// newCv.IRFileAttacments.Add(fileAttachment);
// allCVs.Add(newCv);
// }
// }
// else
// {
// throw new Exception("Mobile number not found " + cv.Name);
// }
// }
// if (allCVs.Count > 0)
// {
// // results= new List<CV>();
// string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
// results = _cvService.SaveCVs(allCVs, connectionString);
// foreach (var temp in results)
// {
// if (temp.ID > 0)
// {
// var cv = cvList?.Where(y => y.SerialId == temp.SerialId)?
// .FirstOrDefault();
// if (cv != null)
// {
// cv.CVId = temp.ID;
// cv.CandidateId = temp.CandidateID;
// }
// }
// }
// }
// }
// }
// catch (Exception ex)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
// }
// return Ok(cvList);
//}
public static string GetFileType(byte[] bytes)
{
if (bytes == null || bytes.Length == 0)
{
return "Unknown";
}
// JPEG
if (bytes.Length >= 2 && bytes[0] == 0xFF && bytes[1] == 0xD8)
{
return "image/jpeg";
}
// PNG
if (bytes.Length >= 8 && bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 &&
bytes[4] == 0x0D && bytes[5] == 0x0A && bytes[6] == 0x1A && bytes[7] == 0x0A)
{
return "image/png";
}
// PDF
if (bytes.Length >= 4 && bytes[0] == 0x25 && bytes[1] == 0x50 && bytes[2] == 0x44 && bytes[3] == 0x46)
{
return "application/pdf";
}
// Add more checks for other file types as needed
return "Unknown";
}
public string extractEducation(string[] wordList)
{
string extractingWords = "";
bool isAllExtract = false;
string[] educationalKeywords = { "education", "educational qualifications", "academic qualification", "academic" };
string[] extractingKeywords = { "secondary", "s.s.c", "ssc", "college" };
for (var i = 0; i < wordList.Length; i++)
{
string currentWord = wordList[i].ToString().ToLower();
if (!string.IsNullOrEmpty(currentWord) && !string.IsNullOrWhiteSpace(currentWord))
{
foreach (string keyword in educationalKeywords)
{
if (currentWord.Contains(keyword))
{
if (currentWord.Trim().Contains("educational") || currentWord.Trim().Contains("education") || currentWord.Trim().Contains("academic"))
{
bool isEducationFound = false;
bool isSSCFound = false;
string nextWord = null;
int lineCount = 0;
int isDigitCount = 0;
if (currentWord.Trim().Contains("education"))
{
isEducationFound = true;
}
for (int j = i; j < wordList.Length; j++)
{
currentWord = wordList[j].ToString().ToLower();
if (isSSCFound)
{
if (currentWord.Trim().Any(char.IsDigit))
{
isDigitCount++;
extractingWords += " " + currentWord;
if (isDigitCount == 2)
break;
else
continue;
}
else if (currentWord.Contains("\n")) //serching for next new line
{
lineCount++;
int newlineIndex = currentWord.IndexOf('\n');
string wordsBeforeNewLine = wordList[j].Substring(0, newlineIndex);
extractingWords += " " + wordsBeforeNewLine;
if (lineCount == 2)
break;
else
continue;
}
else
{
extractingWords += " " + wordList[j];
continue;
}
}
if (currentWord.Contains("qualification") && !isEducationFound) //serching for qualifications
{
isEducationFound = true;
continue;
}
else
{
if (isEducationFound)
{
string wordsAfterIndex = "";
var nextword = wordList[j].Trim().ToLower();
string matchedKeyword = extractingKeywords.FirstOrDefault(keyword => nextword.Contains(keyword));
if (!string.IsNullOrEmpty(matchedKeyword))
{
if (nextword.Contains("secondary") && wordList[j + 1].Trim().ToLower().Contains("school")
|| nextword.Contains("s.s.c") || nextword.Contains("ssc") || nextword.Contains("secondary school"))
{
extractingWords += " " + wordList[j];
isSSCFound = true;
continue;
//isAllExtract = true;
//i = j;
//break;
}
if (nextword.Contains("college"))
{
extractingWords += " " + wordList[j];
isSSCFound = true;
continue;
//isAllExtract = true;
//i = j;
//break;
}
}
int index = wordList[j].ToLower().IndexOf("educational");
if (index != -1)
{
wordsAfterIndex = wordList[j].ToLower().Substring(index + "educational".Length);
extractingWords += " " + wordsAfterIndex;
int index2 = wordList[j + 1].ToLower().IndexOf("qualifications");
if (index2 != -1)
{
wordsAfterIndex = wordList[j + 1].ToLower().Substring(index2 + "qualifications".Length);
extractingWords += " " + wordsAfterIndex;
}
}
else
{
int index1 = wordList[j].ToLower().IndexOf("education");
if (index1 != -1)
{
wordsAfterIndex = wordList[j].ToLower().Substring(index1 + "education".Length);
extractingWords += " " + wordsAfterIndex;
}
extractingWords += " " + wordList[j];
}
continue;
}
continue;
}
}
if (isAllExtract == true)
break;
}
}
}
}
}
int lastIndex = extractingWords.LastIndexOfAny("0123456789".ToCharArray());
// If a digit is found, extract the substring from the beginning up to that index
if (lastIndex != -1)
{
extractingWords = extractingWords.Substring(0, lastIndex + 1); // Adding 1 to include the last digit
}
return extractingWords.Trim();
}
public string extractNames(string[] wordList)
{
bool extratxWords = false;
bool newLineWords = false;
string extractingWords = "";
int count = 0;
for (var i = 0; i < wordList.Length; i++)
{
string currentWord = wordList[i].ToString().ToLower();
if (!string.IsNullOrEmpty(currentWord) && !string.IsNullOrWhiteSpace(currentWord))
{
if (currentWord.Contains("resume") || currentWord.Contains("cv"))
{
if (wordList[i + 1].ToString().ToLower().Contains("of")) // if resume of found then looking for next words
{
i++;
newLineWords = true;
continue;
}
}
else if (currentWord.Contains("name"))
{
extratxWords = true;
}
else if (newLineWords) // extended version of resume of
{
if (count > 0)
{
if (currentWord.Contains("\n")) //serching for next new line
{
int newlineIndex = currentWord.IndexOf('\n');
string wordsBeforeNewLine = wordList[i].Substring(0, newlineIndex);
extractingWords += " " + wordsBeforeNewLine;
break;
}
else
{
extractingWords += " " + wordList[i];
continue;
}
}
extractingWords += " " + wordList[i]; //just extracting next word and not checking new line
count++;
continue;
}
else
{
if (extratxWords == false)
{
extratxWords = true;
extractingWords += " " + wordList[i];
continue;
}
}
}
if (extratxWords && !newLineWords)
{
if (currentWord.Contains("\n")) //serching for next new line
{
int newlineIndex = currentWord.IndexOf('\n');
string wordsBeforeNewLine = wordList[i].Substring(0, newlineIndex);
extractingWords += " " + wordsBeforeNewLine;
extratxWords = false;
break;
}
else
{
extractingWords += " " + wordList[i]; //extracting words before finding the new line
}
}
}
extractingWords = extractingWords.Trim();
if (extractingWords.Where(char.IsDigit).Any())
extractingWords = null;
return extractingWords;
}
public string extractExperience(string[] wordList)
{
string extractingWords = "";
bool isAllExtract = false;
bool isPrevWordWork = false;
bool isExperienceFound = false;
string[] next50Strings = null;
string[] experienceKeywords = { "experience", "experinces" };
for (var i = 0; i < wordList.Length; i++)
{
string currentWord = wordList[i].ToString().ToLower();
if (isPrevWordWork)
{
if (currentWord.Trim().Contains("experience") || currentWord.Trim().Contains("experiences"))
{
isExperienceFound = true;
continue;
}
}
if (!string.IsNullOrEmpty(currentWord) && !string.IsNullOrWhiteSpace(currentWord))
{
if (currentWord.Trim().Contains("work"))
{
if (currentWord.Trim().Contains("experience") || currentWord.Trim().Contains("experiences"))
{
isExperienceFound = true;
break;
}
else
{
isPrevWordWork = true;
continue;
}
}
if (isExperienceFound)
{
next50Strings = new string[Math.Min(200, wordList.Length - i)];
Array.Copy(wordList, i, next50Strings, 0, next50Strings.Length);
break;
}
}
}
int isDigitCount = 0;
bool istilwordfound = false;
string tillWords = null;
if (next50Strings != null)
{
for (var i = 0; i < next50Strings.Length; i++)
{
string currentWord = next50Strings[i].ToString().ToLower();
//if (currentWord.Trim().Contains("present"))
//{
// extractingWords += " " + next50Strings[i];
// for(var j = i; j < 5; j++)
// {
// extractingWords += " " + next50Strings[j];
// }
// istilwordfound = true;
// break;
//}
if (currentWord.Trim().Contains("till"))
{
tillWords += " " + next50Strings[i] + " " + next50Strings[i + 1];
for (var j = i; j < 5; j++)
{
tillWords += " " + next50Strings[j];
}
istilwordfound = true;
break;
}
else
{
tillWords += " " + next50Strings[i];
}
}
if (istilwordfound)
{
extractingWords = tillWords;
}
if (!istilwordfound)
{
string lastString = null;
List<string> digits = new List<string>();
foreach (string str in next50Strings)
{
if (str.ToString().ToLower().Contains("present"))
{
digits.Add(str);
}
var numericPart = new string(str.Where(char.IsDigit).ToArray());
if (!string.IsNullOrEmpty(numericPart))
{
digits.Add(numericPart);
}
}
if (digits != null && digits.Count > 0)
lastString = digits[digits.Count - 1];
if (!string.IsNullOrEmpty(lastString))
{
for (var i = 0; i < next50Strings.Length; i++)
{
string currentWord = next50Strings[i].ToString().ToLower();
if (currentWord.Trim().Contains(lastString))
{
extractingWords += " " + next50Strings[i];
bool isDigitinSameWord = false;
string extractingWords1 = null;
for (var j = i + 1; j < next50Strings.Length; j++)
{
string next = next50Strings[j].ToString().ToLower();
if (next.Trim().Contains(lastString))
{
isDigitinSameWord = true;
extractingWords1 += " " + next50Strings[j];
break;
}
else
{
extractingWords1 += " " + next50Strings[j];
}
}
if (isDigitinSameWord)
{
extractingWords = next50Strings + extractingWords1;
}
}
else
{
extractingWords += " " + next50Strings[i];
}
}
}
}
}
int index = extractingWords.IndexOf("education", StringComparison.OrdinalIgnoreCase);
if (index != -1)
{
extractingWords = extractingWords.Substring(0, index);
}
return extractingWords.Trim();
}
public string extractSkills(string input)
{
string extractWords = "";
int index = -1;
string targetWord = "";
if (input.ToLower().Contains("skill"))
{
if (input.ToLower().Contains("skills"))
{
index = input.ToLower().IndexOf("skills");
targetWord = "skills";
}
else if (input.ToLower().Contains("skill"))
{
index = input.ToLower().IndexOf("skill");
targetWord = "skill";
}
if (index != -1)
{
//int newlineIndex = input.IndexOf('\n', index);
// Extract the substring starting from the index of "MySql" to the next 200 characters
string result = input.Substring(index + targetWord.Length, Math.Min(500, input.Length - (index + targetWord.Length)));
string[] lines = result.Split('\n');
string[] firstFiveLines = new string[Math.Min(10, lines.Length)];
Array.Copy(lines, firstFiveLines, firstFiveLines.Length);
foreach (string line in firstFiveLines)
{
extractWords += line;
}
}
}
//if (input.ToLower().Contains("skills"))
//{
// int index = input.ToLower().IndexOf("skills");
// if (index != -1)
// {
// // Extract the substring starting from the index of "MySql" to the next 200 characters
// string result = input.Substring(index + "skills".Length, Math.Min(500, input.Length - (index + "skills".Length)));
// string[] lines = result.Split('\n');
// string[] firstFiveLines = new string[Math.Min(4, lines.Length)];
// Array.Copy(lines, firstFiveLines, firstFiveLines.Length);
// foreach (string line in firstFiveLines)
// {
// extractWords += line;
// }
// }
//}
return extractWords.Trim();
}
[HttpPost]
[Route("saveJobTracking")]
public ActionResult SaveJobTracking(RecJobTracking item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
item.CreatedBy = currentUser.UserID;
item.CreatedDate = DateTime.Today;
try
{
this._recJobTrackingService.Save(item);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("completeJobPostingPreparationDate")]
public ActionResult completeJobPostingPreparationDate(RecJobTracking item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
if(item.ID > 0)
{
if(item.ActualJobPostingPreparationEndDate == null)
throw new Exception("Please enter a valid date");
else this._recJobTrackingService.CompleteJobPostingPreparationDate(item);
}
else throw new Exception("Please Save the Job Tracking First");
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpPost]
[Route("completeJobPostingDate")]
public ActionResult completeJobPostingDate(RecJobTracking item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
if (item.ID > 0)
{
if (item.ActualJobPostingEndDate == null)
throw new Exception("Please enter a valid date");
else this._recJobTrackingService.CompleteJobPostingDate(item);
}
else throw new Exception("Please Save the Job Tracking First");
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(true);
}
[HttpGet]
[Route("getByRecruitmentId/{recruitmentId}")]
public ActionResult GetByRecruitmentId(int recruitmentId)
{
RecJobTracking item = null;
try
{
InternalRecruitment oInternalRecuitment = _internalRecruitmentService.Get(recruitmentId);
item = _recJobTrackingService.GetByRecruitmentId(recruitmentId);
if(item != null)
{
item.JobPostingPreparationDays = (item.JobPostingPreparationDate - item.TrackingStartDate).Days;
item.JobPostingDays=(item.JobPostingDate - item.JobPostingPreparationDate).Days;
item.CvCollectionDays = (item.CvCollectionDate - item.JobPostingDate).Days;
item.InterviewStartDays = (item.InterviewStartDate - item.CvCollectionDate).Days;
item.InterviewEndDays = (item.InterviewEndDate - item.InterviewStartDate).Days;
item.OfferLetterSendDays = (item.OfferLetterSendDate - item.InterviewEndDate).Days;
item.JoiningDays = item.JoiningDate != null ? (Convert.ToDateTime(item.JoiningDate) - item.OfferLetterSendDate).Days : 0;
}
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(item);
}
//[HttpGet]
//[Route("getByRecruitmentId/{recruitmentId}")]
//public ActionResult GetByRecruitmenWithRecJob(int recruitmentId)
//{
// RecJobTracking item = null;
// try
// {
// item = _recJobTrackingService.GetByRecruitmentId(recruitmentId);
// if (item != null)
// {
// item.JobPostingDays = (item.JobPostingDate - item.TrackingStartDate).Days;
// item.CvCollectionDays = (item.CvCollectionDate - item.JobPostingDate).Days;
// item.InterviewStartDays = (item.InterviewStartDate - item.CvCollectionDate).Days;
// item.InterviewEndDays = (item.InterviewEndDate - item.InterviewStartDate).Days;
// item.OfferLetterSendDays = (item.OfferLetterSendDate - item.InterviewEndDate).Days;
// item.JoiningDays = (item.JoiningDate - item.OfferLetterSendDate).Days;
// }
// }
// catch (Exception ex)
// {
// return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
// }
// return Ok(item);
//}
[HttpPost]
[Route("getRecruitmentTracking")]
public ActionResult GetRecruitmentTracking(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
DateTime? startDate = items["startDate"] == null ? null : (DateTime)items["startDate"].ToObject<DateTime>();
DateTime? endDate = items["endDate"] == null ? null : (DateTime)items["endDate"].ToObject<DateTime>();
int recruitmentId = items["recruitmentid"] == null ? 0 : items["recruitmentid"].ToObject<int>();
int recruiterId = items["recruiterid"] == null ? 0 : items["recruiterid"].ToObject<int>();
EnumOnBoradStatus? onBoardStatus = items["status"] == null ? null: (EnumOnBoradStatus)items["status"].ToObject<int>();
DataSet ds = new DataSet();
try
{
ds = _internalRecruitmentService.GetRecruitment(startDate, endDate, onBoardStatus, recruitmentId, recruiterId, currentUser.UserID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ds);
}
[HttpPost]
[Route("getGetRequisitionChart")]
public ActionResult GetRequisitionChart(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
DateTime? startDate = items["fromDate"] == null ? null : (DateTime)items["fromDate"].ToObject<DateTime>();
DateTime? endDate = items["fromDate"] == null ? null : (DateTime)items["toDate"].ToObject<DateTime>();
DataSet ds = new DataSet();
try
{
ds = _internalRecruitmentService.GetRequisitionChart((DateTime)startDate, (DateTime)endDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ds);
}
[HttpPost]
[Route("UpdateCvInfo")]
public ActionResult UpdateCvInfo(dynamic data)
{
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
//int recruitmentId = items["recruitmentid"] == null ? 0 : items["recruitmentid"].ToObject<int>();
//int recruiterId = items["recruiterid"] == null ? 0 : items["recruiterid"].ToObject<int>();
//EnumOnBoradStatus? onBoardStatus = items["status"] == null ? null : (EnumOnBoradStatus)items["status"].ToObject<int>
string name = items["name"] == null ? "undefined" : items["name"].ToObject<string>();
string mobile = items["mobile"] == null ? "undefined" : items["mobile"].ToObject<string>();
string email = items["email"] == null ? "undefined" : items["email"].ToObject<string>();
string reference = items["reference"] == null ? "undefined" : items["reference"].ToObject<string>();
string education = items["education"] == null ? "undefined" : items["education"].ToObject<string>();
string experience = items["experience"] == null ? "undefined" : items["experience"].ToObject<string>();
string skill = items["skill"] == null ? "undefined" : items["skill"].ToObject<string>();
int cvId = items["cvId"] == null ? 0 : items["cvId"].ToObject<int>();
int requisitionID = items["requisitionID"] == null ? 0 : items["requisitionID"].ToObject<int>();
name = (name == "undefined" || name == "null") ? string.Empty : name;
email = (email == "undefined" || email == "null") ? string.Empty : email;
mobile = (mobile == "undefined" || mobile == "null") ? string.Empty : mobile;
reference = (reference == "undefined" || reference == "null") ? string.Empty : reference;
education = (education == "undefined" || education == "null") ? string.Empty : education;
experience = (experience == "undefined" || experience == "null") ? string.Empty : experience;
skill = (skill == "undefined" || skill == "null") ? string.Empty : skill;
var existingCvList = _cvService.EmailAndPhoneDuplicateCheck(mobile, null);
if(existingCvList !=null && existingCvList.Count >0)
{
return StatusCode(StatusCodes.Status500InternalServerError,
"A CV already exist by this Mobile Number: " + mobile);
}
try
{
_cvService.UpdateCvNameMobileEmail(cvId, name, mobile, email, reference, education, experience, skill, requisitionID);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok();
}
[HttpPost]
[Route("deleteCvSort")]
public ActionResult deleteCvSort(CVSort ob)
{
try
{
_cvService.DeleteCvsort(ob);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("getRequisitionReports")]
public ActionResult GetRequisitionReports(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
DateTime? startDate = items["fromDate"] == null ? null : (DateTime)items["fromDate"].ToObject<DateTime>();
DateTime? endDate = items["fromDate"] == null ? null : (DateTime)items["toDate"].ToObject<DateTime>();
DataSet ds = new DataSet();
try
{
ds = _internalRecruitmentService.GetRequisitionReports((DateTime)startDate, (DateTime)endDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ds);
}
[HttpPost]
[Route("getRequisitionCountReport")]
public ActionResult GetRequisitionCountReport(dynamic data)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
DateTime? startDate = items["fromDate"] == null ? null : (DateTime)items["fromDate"].ToObject<DateTime>();
DateTime? endDate = items["fromDate"] == null ? null : (DateTime)items["toDate"].ToObject<DateTime>();
DataSet ds = new DataSet();
try
{
ds = _internalRecruitmentService.GetRequisitionAllCountReport((DateTime)startDate, (DateTime)endDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(ds);
}
[HttpGet]
[Route("getInterviewAssesmentKpis")]
public ActionResult GetInterviewAssesmentKpis()
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<InterviewAssessmentKPI> list= new List<InterviewAssessmentKPI>();
try
{
list = _interviewAssessmentKPIService.Get();
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(list);
}
[HttpGet]
[Route("getinterviewassessmentkpiBySessionIDStepID/{sessionID}/{stepID}")]
public ActionResult GetinterviewassessmentkpiBySessionIDStepID(int sessionID, int stepID)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<InterviewAssessmentKPI> list = new List<InterviewAssessmentKPI>();
try
{
list = _interviewAssessmentKPIService.GetBySessionIDStepID(sessionID, stepID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(list);
}
[HttpPost]
[Route("getBoardbyBoardMemberIdCandidateIdSessionId")]
public ActionResult getBoardbyBoardMemberIdCandidateIdSessionId(dynamic data)
{
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
int candidateID = items["candidateID"] == null ? 0 : items["candidateID"].ToObject<int>();
int interviewBoardMemberID = items["interviewBoardMemberID"] == null ? 0 : items["interviewBoardMemberID"].ToObject<int>();
int sessionID = items["sessionID"] == null ? 0 : items["sessionID"].ToObject<int>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<InterviewBoardAssessmentKPI> list = new List<InterviewBoardAssessmentKPI>();
try
{
list = _interviewAssessmentKPIService.GetBoardbyBoardMemberIdCandidateIdSessionId(candidateID, interviewBoardMemberID, sessionID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(list);
}
[HttpPost]
[Route("saveInterviewBoardKpi")]
public ActionResult saveInterviewBoardKpi(List<InterviewBoardAssessmentKPI> items)
{
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
//items = items.Select(item => { item.InterviewBoardMemberID = currentUser.UserID;
// return item;
// }).ToList();
foreach (InterviewBoardAssessmentKPI item in items)
{
if (item.IsNew == true)
{
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedBy = (int)currentUser.EmployeeID;
item.ModifiedDate = DateTime.Today;
}
}
_interviewAssessmentKPIService.SaveBoardKpis(items);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("updateMarkInfo")]
public void updateMarkInfo(RecruitmentMarkExtend item)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
try
{
if (item.IsNew == true)
{
item.CreatedDate = DateTime.Today;
}
else
{
item.ModifiedDate = DateTime.Today;
}
_recruitementProcessService.UpdateInterviewAssesmentMark(item);
}
catch (Exception ex)
{
StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
}
[HttpPost]
[Route("SaveOfferLetter")]
public ActionResult SaveOfferLetter(dynamic data)
{
try
{
string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
if(connectionString == string.Empty)
throw new Exception("SqlCommandConnection not found");
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
string letterType = items["letterType"] == null ? string.Empty : items["letterType"].ToObject<string>();
string ccMail = items["ccMail"] == null ? string.Empty : items["ccMail"].ToObject<string>();
RecruitmentLetters recruitmentLetter = items["recruitmentLetter"] == null ? null : items["recruitmentLetter"].ToObject<RecruitmentLetters>();
CV cv = items["cv"] == null ? null : items["cv"].ToObject<CV>();
var fileList = items["fileList"]?.ToObject<List<dynamic>>();
string fileName = string.Empty;
string fileTobase64 = string.Empty;
string[] fileBytes = null;
List<Attachment> attList = new List<Attachment>(); //Mail attachment
foreach (var file in fileList)
{
fileName = file["fileName"]?.ToString();
fileTobase64 = file["fileBase64"]?.ToString();
if (fileName != null && fileTobase64 != null)
{
fileBytes = new string[0];
if (fileTobase64 != string.Empty)
fileBytes = fileTobase64.Split(new char[] { ',', ' ' }, StringSplitOptions.None);
Attachment att = new Attachment(new MemoryStream(Convert.FromBase64String(fileBytes[1])), fileName);
attList.Add(att);
}
}
#region check letter status
RecruitmentLetters letter = new RecruitmentLettersService().Get(recruitmentLetter.ID);
if(letter != null)
{
if (letterType == "offerLetter")
{
if (recruitmentLetter.OfferLetterCreatedDate != DateTime.MinValue)
{
throw new Exception($"Offer Letter already has been sent for Candidate: {recruitmentLetter.CV?.Name}");
}
}
if (letterType == "appointmentLetter")
{
if (letter.AppointmentLetterCreatedDate != DateTime.MinValue)
{
throw new Exception($"Appointment Letter already has been sent for Candidate: {recruitmentLetter.CV?.Name}");
}
if (letter.OfferLetterCreatedDate == DateTime.MinValue)
{
throw new Exception($"Please send Offer Letter first, for Candidate: {recruitmentLetter.CV?.Name}");
}
}
if (letterType == "joiningInformation")
{
if (letter.JoiningInformationLetterCreatedDate != DateTime.MinValue)
{
throw new Exception($"Joining Information already has been sent for Candidate: {recruitmentLetter.CV?.Name}");
}
if (letter.OfferLetterCreatedDate == DateTime.MinValue)
{
throw new Exception($"Please send Offer Letter first, for Candidate: {recruitmentLetter.CV?.Name}");
}
if (letter.AppointmentLetterCreatedDate == DateTime.MinValue)
{
throw new Exception($"Please send Appointment Letter first, for Candidate: {recruitmentLetter.CV?.Name}");
}
}
}
#endregion
#region letterType
MailSender mailSender = new MailSender();
mailSender.Body = "<div style='font-family: Arial; font-size: 11pt;'>";
InternalRecruitment requisition = new InternalRecruitment();
if (recruitmentLetter != null)
requisition = new InternalRecruitmentService().Get(recruitmentLetter.RequisitionID);
string positionName = requisition != null ? requisition.PositionName : "N/A";
string locationName = requisition != null ? requisition.LocationName : "N/A";
List<Department> depts = new DepartmentService().GetAll();
List<Designation> designations = new DesignationService().GetAll();
string departmentName = requisition != null ? depts.FirstOrDefault(d => d.ID == requisition?.DepartmentId).Name : string.Empty;
string designationName = requisition != null ? designations.FirstOrDefault(d => d.ID == requisition?.DesignationId).Name : string.Empty;
if (letterType == "offerLetter")
{
recruitmentLetter.OfferLetterFileName = fileName;
recruitmentLetter.OfferLetterCreatedBy = currentUser.UserID;
recruitmentLetter.OfferLetterCreatedDate = DateTime.Today;
recruitmentLetter.OfferLetterFileAsByteArray = Convert.FromBase64String(fileBytes[1]);
mailSender.Subject = "Job offer for the position of " + positionName + " Under "+departmentName;
mailSender.Body += $@"<p>Dear {cv?.Name},</p>
<p>Greetings from SGS Bangladesh Limited!</p>
<p>We are delighted to extend this job offer to you. We trust that your Skills & Experiences will be an asset to our company & hopefully you will also enjoy your professional career with us.</p>
<p>Please review the attached information (Confidential) & share your feedback with us.</p>
<p></p>";
}
if (letterType == "appointmentLetter")
{
recruitmentLetter.AppointmentLetterFileName = fileName;
recruitmentLetter.AppointmentLetterCreatedBy = currentUser.UserID;
recruitmentLetter.AppointmentLetterCreatedDate = DateTime.Today;
recruitmentLetter.AppointmentLetterFileAsByteArray = Convert.FromBase64String(fileBytes[1]);
string appointmentLetterDeadline = Convert.ToDateTime(recruitmentLetter.AppointmentLetterDeadline).ToString("dd MMMM yyyy");
string appointmentLetterEmail = recruitmentLetter.AppointmentLetterEmail;
mailSender.Subject = "Appointment Letter for the position of " + positionName + " Under " + departmentName;
mailSender.Body += $@"<p>Dear {cv?.Name},</p>
<p>Congratulations!</p>
<p>Please find your appointment letter for the position of {positionName} under {departmentName} department, attached to this email.</p>
<p>We kindly request you to review, sign and return the signed copy to this email address: {appointmentLetterEmail} , CC: {ccMail} by {appointmentLetterDeadline}. If you have any questions or require clarification, feel free to reach out.</p>
<p>We are excited to have you join our SGS Family</p>
<p></p>
<p>Best regards,</p>
<p>SGS, HR</p>";
}
if (letterType == "joiningInformation")
{
//for single attachment save
recruitmentLetter.JoiningInformationLetterFileName = fileName;
recruitmentLetter.JoiningInformationLetterCreatedBy = currentUser.UserID;
recruitmentLetter.JoiningInformationLetterCreatedDate = DateTime.Today;
recruitmentLetter.JoiningInformationLetterFileAsByteArray = null;
//string folderPath = @"D:\Recruitment Documents";
//if (!Directory.Exists(folderPath))
// throw new Exception("Folder not found: " + folderPath);
//string[] files = Directory.GetFiles(folderPath);
//if (files.Length == 0) throw new Exception("No files found in the folder. Please add necessary documents in: " + folderPath);
//foreach (string file in Directory.GetFiles(folderPath))
//{
// Attachment att = new Attachment(file);
// attList.Add(att);
//}
string JoiningDate = Convert.ToDateTime(recruitmentLetter.JoiningDate).ToString("dd MMMM yyyy");
string submissionDate = Convert.ToDateTime(recruitmentLetter.JoiningDate).AddDays(-7).ToString("dd MMMM yyyy");
mailSender.Subject = "Necessary Documents for Joining " + positionName + " Under " + departmentName;
mailSender.Body += $@"
<p>Dear {cv?.Name},</p>
<p>Greetings of the day & Welcome to SGS Family!</p>
<p>
With reference to our job offer, Please find the attached documents which fill up guidelines are as below
and will be submitted at the time of your joining which is <strong>{JoiningDate}</strong>. Requesting you
to report in our <strong>Gulshan Office</strong> on that day at <strong>9:30 am</strong>.
</p>
<p>
<span style='background-color: yellow; font-weight: bold;'>Please note:</span> One form (Information Blank) on MS Word format
has attached. You are requested to fill it up and send us by <strong>{submissionDate}</strong>
through Email along with your NID copy.
</p>
<ol>
<li>
<strong>Checklist for Personal File</strong> - You are required to bring the necessary documents according
to the list of documents provided, but please <strong>do not</strong> fill the chart.
</li>
<li>
<strong>Information Blank</strong> - Here you are required to give your information.
<p>
Please be noted that, on the last page where you are required to put reference, please give the reference of:
</p>
<ul>
<li>Your Last Supervisor</li>
<li>One of Your Academicians</li>
<li>One of Your Relatives/Acquaintances</li>
</ul>
</li>
<li>
<strong>Nominee Form</strong> - You can have a maximum of 3 and a minimum of 1 nominee(s) who would avail of the financial benefits
in your absence from the company. The nominee(s) should preferably be your family members/relatives.
You will also find a row for Witness who would witness you and your nominees while signing.
<p><em>Under no circumstances, should the nominee(s) or witness be below 18 years of age.</em></p>
</li>
<li><strong>Joining Report</strong> – You are required to fill the first half of the sheet.</li>
<li>
<strong>Recruitment Process Feedback Form</strong> – Feel free to share your honest opinion about our recruitment process.
</li>
<li>
<strong>Bank Form</strong> – Please fill as instructed (If you already have accounts with SCB, then bring any copy of proof of your account).
</li>
<li>
<strong>Health Insurance Inclusion Form</strong> – Please fill with the required information.
</li>
</ol>
<p>If you have any queries, please feel free to contact us.</p>
";
}
#endregion
#region Save File
if (recruitmentLetter.IsNew == true)
{
recruitmentLetter.CreatedBy = (int)currentUser.EmployeeID;
recruitmentLetter.CreatedDate = DateTime.Today;
}
else
{
recruitmentLetter.ModifiedBy = (int)currentUser.EmployeeID;
recruitmentLetter.ModifiedDate = DateTime.Today;
}
new RecruitmentLettersService().SaveOfferLetter(recruitmentLetter, letterType);
#endregion
#region Send Mail
mailSender.Body += "</div>";
EmailSettings emailSettings = _emailSettings.Value;
if (cv?.Email == null)
throw new Exception("Email address not found for CV");
mailSender.AddTo(cv.Email.ToString());
//mailSender.AddTo("alvee@celimited.com");
if (!string.IsNullOrEmpty(ccMail))
mailSender.CC = ccMail;
mailSender.SendMail(emailSettings, attList);
#endregion
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
[HttpPost]
[Route("SendMailToLM")]
public ActionResult SendMailToLM(dynamic data)
{
try
{
string connectionString = _config.GetSection("dbSettings").GetSection("SqlCommandConnection").Value;
if (connectionString == string.Empty)
throw new Exception("SqlCommandConnection not found");
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data));
List<RecruitmentLetters> recruitmentLetters = items["recruitmentLetters"] == null ? null : (List<RecruitmentLetters>)items["recruitmentLetters"].ToObject<List<RecruitmentLetters>>();
string ccMail = items["ccMail"] == null ? string.Empty : items["ccMail"].ToObject<string>();
var fileList = items["fileList"]?.ToObject<List<dynamic>>();
List<Attachment> attList = new List<Attachment>(); //Mail attachment
foreach (var file in fileList)
{
string fileName = file["fileName"]?.ToString();
string fileBase64 = file["fileBase64"]?.ToString();
if (fileName != null && fileBase64 != null)
{
string[] fileBytes = new string[0];
if (fileBase64 != string.Empty)
fileBytes = fileBase64.Split(new char[] { ',', ' ' }, StringSplitOptions.None);
Attachment att = new Attachment(new MemoryStream(Convert.FromBase64String(fileBytes[1])), fileName);
attList.Add(att);
}
}
int linemnaagerId = items["linemnaagerId"] == null ? 0 : items["linemnaagerId"].ToObject<int>();
Employee lineManager = new Employee();
if(linemnaagerId != 0)
lineManager = new EmployeeService().Get(linemnaagerId);
InternalRecruitment requisition = new InternalRecruitment();
string cvEmails = string.Empty;
if (recruitmentLetters.Count() > 0)
{
requisition = new InternalRecruitmentService().Get(recruitmentLetters[0].RequisitionID);
cvEmails = string.Join(";", recruitmentLetters.Select(r => r.CV.Email ?? string.Empty).Where(email => !string.IsNullOrWhiteSpace(email)));
}
string positionName = requisition?.PositionName != null ? requisition.PositionName : "N/A";
string locationName = requisition?.LocationName != null ? requisition.LocationName : "N/A";
List<Department> depts = new DepartmentService().GetAll();
List<Designation> designations = new DesignationService().GetAll();
string departmentName = requisition != null ? depts.FirstOrDefault(d => d.ID == requisition?.DepartmentId).Name : string.Empty;
string designationName = requisition != null ? designations.FirstOrDefault(d => d.ID == requisition?.DesignationId).Name : string.Empty;
#region Save File
foreach (RecruitmentLetters recruitmentLetter in recruitmentLetters)
{
if (recruitmentLetter.IsNew == true)
{
recruitmentLetter.CreatedBy = (int)currentUser.EmployeeID;
recruitmentLetter.CreatedDate = DateTime.Today;
}
else
{
recruitmentLetter.ModifiedBy = (int)currentUser.EmployeeID;
recruitmentLetter.ModifiedDate = DateTime.Today;
}
recruitmentLetter.MailToLMLetterCreatedDate = DateTime.Today;
recruitmentLetter.MailToLMLetterCreatedBy = (int)currentUser.EmployeeID;
new RecruitmentLettersService().SaveOfferLetter(recruitmentLetter, "mailToLM");
}
#endregion
#region Mail
MailSender mailSender = new MailSender();
mailSender.Subject = "New joiner Information & need Information for SHINE Activities (" + departmentName + ")";
mailSender.Body = "<div style='font-family: Arial; font-size: 11pt;'>";
StringBuilder tableRows = new StringBuilder();
if (recruitmentLetters != null)
{
int serial = 1;
foreach (var recruitmentLetter in recruitmentLetters)
{
tableRows.Append($@"
<tr>
<td>{serial}</td>
<td>{recruitmentLetter.CV.Name ?? "-"}</td>
<td>{recruitmentLetter.JoiningDate:dd MMMM yyyy}</td>
<td>{designationName ?? "-"}</td>
<td>{recruitmentLetter.CV.Mobile ?? "-"}</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>");
serial++;
}
}
string emailBody=$@"<p>Dear {lineManager?.Name},</p>
<p>Greetings of the Day!</p>
<p>Requesting you to provide us the below information for the new resources to your department and please be informed that the below employees will be under the Department: {departmentName}:</p>
<p>Please forward the below information to {positionName} in {departmentName}.</p>
<table border='1' style='border-collapse: collapse; width: 100%; text-align: left;'>
<thead style='background-color: #f4a460;'>
<tr>
<th> Sl.</th>
<th> Name of the New joiners</th>
<th> Joining Date </th>
<th> Selected Designation </th>
<th> Phone</th>
<th> Replacement Against(Name & ID) </th>
<th> Peer Advisor's ID</th>
<th> Peer Advisor's Name</th>
<th> Peer Advisor's Email ID</th>
<th> Peer Advisor's Contact No.</th>
<th> Manager's ID</th>
<th> Manager's Name</th>
<th> Manager's Email ID</th>
<th> Manager's Contact No.</th>
</tr>
</thead>
<tbody>
{tableRows}
</tbody>
</table>
<p>Requesting your kind attention before selecting the Peer Advisors. As you know it should be a 1:1 ratio unless it's rare. And he/she must be a good performer with more than 1-year experience in SGS and having good knowledge of our business and good communication skills. Also, please be careful in regards to the position as the new joiner is in an entry-level position so the Peer Advisor must be at the same level unless the criteria are critical to match.</p>";
mailSender.Body += emailBody;
mailSender.Body += "</div>";
//new RecruitmentLettersService().SaveOfferLetter(connectionString, recruitmentLetter, letterType);
EmailSettings emailSettings = _emailSettings.Value;
if (lineManager?.EmailAddress == string.Empty)
throw new Exception("Email address not found for Line Manager");
mailSender.AddTo(lineManager.EmailAddress);
if (!string.IsNullOrEmpty(ccMail))
mailSender.CC = ccMail;
//mailSender.Subject = "New Joiner Information & need Information for SHINE Activities (C & P Physical Lab.)";
#region sending stored file from Documents
//List <Attachment> attList = new List<Attachment>();
//string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
//if (!Directory.Exists(folderPath))
// throw new Exception("Folder not found. Create a folder in this path: " + folderPath);
//string[] files = Directory.GetFiles(folderPath);
//if (files.Length == 0) throw new Exception("No files found in the folder. Please add necessary documents in: " + folderPath);
//foreach (string file in Directory.GetFiles(folderPath))
//{
// Attachment att = new Attachment(file);
// attList.Add(att);
//}
#endregion
mailSender.SendMail(emailSettings, attList);
#endregion
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok();
}
}
}