Exemplo n.º 1
0
        public int CreateRequisition(TblRequisition tblRequisition)
        {
            tblRequisition.IsActive               = true;
            tblRequisition.CreatedDate            = DateTime.Now;
            tblRequisition.CreatedBy              = CurrentContext.EmployeeID;
            tblRequisition.Status                 = RequisitionStatus.Open;
            tblRequisition.ManagerEmployeeId      = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == CurrentContext.EmployeeID).FirstOrDefault().ReportingManagerId;
            tblRequisition.CurrentOwner           = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == tblRequisition.ManagerEmployeeId).FirstOrDefault().EmployeeName;
            dbContext.Entry(tblRequisition).State = EntityState.Added;
            dbContext.TblRequisition.Add(tblRequisition);
            int result = dbContext.SaveChanges();

            dbContext.Entry(tblRequisition).State = EntityState.Detached;
            foreach (TblRequisitionSkillMapping mapping in tblRequisition.TblRequisitionSkillMapping)
            {
                mapping.RequisitionId = tblRequisition.RequistionId;
                dbContext.TblRequisitionSkillMapping.Add(mapping);
            }
            dbContext.SaveChanges();
            var obj = dbContext.TblRequisition.AsNoTracking().Where(r => r.RequistionId == tblRequisition.RequistionId).Include(r => r.Department).Include(r => r.Designation).Include(r => r.TblRequisitionSkillMapping).FirstOrDefault();

            if (result > 0)
            {
                SendRequisitionRaisedMail(obj);
            }
            dbContext.Entry(obj).State = EntityState.Detached;
            return(result);
        }
Exemplo n.º 2
0
        private async void SendRequisitionAssignedMail(TblRequisition tblRequisition)
        {
            EmailTemplate emailTemplate = new EmailTemplate();
            StringBuilder stringBuilder = new StringBuilder();
            TblEmployees  tblEmployees  = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == tblRequisition.CreatedBy).FirstOrDefault();

            stringBuilder.AppendLine(tblEmployees.EmployeeName + "- has raised Requisition");
            stringBuilder.AppendLine("Requisition Title : " + tblRequisition.Title);
            stringBuilder.AppendLine("Skills : " + string.Join(",", dbContext.TblSkillMaster.Where(q => q.SkillId == tblRequisition.RequistionId).Select(x => x.SkillName).ToArray()));
            stringBuilder.AppendLine("Department : " + tblRequisition.Department.Department);
            stringBuilder.AppendLine("Designation : " + tblRequisition.Designation.Designation);
            stringBuilder.AppendLine("Years Of Experience : " + tblRequisition.YearsofExperience);
            stringBuilder.AppendLine("Joining Tenure(Months) : " + tblRequisition.JoiningTenure);
            stringBuilder.AppendLine("No Of Positions : " + tblRequisition.NoofPositions);
            stringBuilder.AppendLine("Location : " + tblRequisition.Location);
            stringBuilder.AppendLine("Comments : " + tblRequisition.Comments);
            stringBuilder.AppendLine("Manager Comments : " + tblRequisition.ManagerComments);
            stringBuilder.AppendLine("Recruiter Comments : " + tblRequisition.RecruiterComment);
            emailTemplate.Body    = stringBuilder.ToString();
            emailTemplate.Subject = "Requisition has been Assigned to you";
            emailTemplate.EmailFromDisplayName = tblEmployees.EmployeeName;
            string[] MailIds = new string[tblRequisition.TblRequisitionRecruiterMapping.Count + 1];
            for (int i = 0; tblRequisition.TblRequisitionRecruiterMapping.Count > i; i++)
            {
                TblRequisitionRecruiterMapping recruiter = tblRequisition.TblRequisitionRecruiterMapping.ElementAt(i);
                MailIds[i] = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == recruiter.EmployeeId).FirstOrDefault().EmailId;
            }
            MailIds[MailIds.Length - 1]  = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == tblRequisition.CreatedBy).FirstOrDefault().EmailId;
            emailTemplate.ToEmailAddress = MailIds;
            await EmailHelper.SendMailWithoutCalendarInvite(emailTemplate);
        }
Exemplo n.º 3
0
        public int DeleteRequisition(int key)
        {
            TblRequisition tblRequisition = dbContext.TblRequisition.Where(e => e.RequistionId == key).FirstOrDefault();

            tblRequisition.IsActive = false;
            dbContext.Entry(tblRequisition).State = EntityState.Modified;
            dbContext.TblRequisition.Update(tblRequisition);
            dbContext.SaveChanges();
            dbContext.Entry(tblRequisition).State = EntityState.Detached;
            dbContext.TblRequisitionSkillMapping.RemoveRange(dbContext.TblRequisitionSkillMapping.Where(r => r.RequisitionId == tblRequisition.RequistionId));
            dbContext.SaveChanges();
            return(1);
        }
Exemplo n.º 4
0
        public int CloseRequisition(TblRequisition tblRequisition)
        {
            tblRequisition.TblRequisitionRecruiterMapping = null;
            tblRequisition.TblRequisitionSkillMapping     = null;
            tblRequisition.ModifiedDate           = DateTime.Now;
            tblRequisition.ModifiedBy             = CurrentContext.EmployeeID;
            tblRequisition.CurrentOwner           = "N/A";
            dbContext.Entry(tblRequisition).State = EntityState.Modified;
            dbContext.TblRequisition.Update(tblRequisition);
            int result = dbContext.SaveChanges();

            dbContext.Entry(tblRequisition).State = EntityState.Detached;
            return(result);
        }
Exemplo n.º 5
0
        private async void SendRequisitionApprovedMail(TblRequisition tblRequisition)
        {
            EmailTemplate emailTemplate = new EmailTemplate();
            StringBuilder stringBuilder = new StringBuilder();
            TblEmployees  tblEmployees  = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == tblRequisition.CreatedBy).FirstOrDefault();

            stringBuilder.AppendLine(tblEmployees.EmployeeName + "- has raised Requisition");
            stringBuilder.AppendLine("Requisition Title : " + tblRequisition.Title);
            stringBuilder.AppendLine("Skills : " + string.Join(",", dbContext.TblSkillMaster.Where(q => q.SkillId == tblRequisition.RequistionId).Select(x => x.SkillName).ToArray()));
            stringBuilder.AppendLine("Department : " + tblRequisition.Department.Department);
            stringBuilder.AppendLine("Designation : " + tblRequisition.Designation.Designation);
            stringBuilder.AppendLine("Years Of Experience : " + tblRequisition.YearsofExperience);
            stringBuilder.AppendLine("Joining Tenure(Months) : " + tblRequisition.JoiningTenure);
            stringBuilder.AppendLine("No Of Positions : " + tblRequisition.NoofPositions);
            stringBuilder.AppendLine("Location : " + tblRequisition.Location);
            stringBuilder.AppendLine("Comments : " + tblRequisition.Comments);
            stringBuilder.AppendLine("Manager Comments : " + tblRequisition.ManagerComments);
            emailTemplate.Body    = stringBuilder.ToString();
            emailTemplate.Subject = "Requisition Approved";
            emailTemplate.EmailFromDisplayName = tblEmployees.EmployeeName;
            emailTemplate.ToEmailAddress       = dbContext.TblEmployees.AsNoTracking().Where(r => r.Role.RoleName == RoleConstants.RecruiterLeadRole && r.EmployeeId == tblRequisition.CreatedBy).AsNoTracking().ToList().Select(r => r.EmailId).ToArray();
            await EmailHelper.SendMailWithoutCalendarInvite(emailTemplate);
        }
Exemplo n.º 6
0
        public int UpdateRequisition(TblRequisition tblRequisition)
        {
            tblRequisition.ModifiedDate      = DateTime.Now;
            tblRequisition.IsActive          = true;
            tblRequisition.ModifiedBy        = CurrentContext.EmployeeID;
            tblRequisition.ManagerEmployeeId = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == CurrentContext.EmployeeID).AsNoTracking().FirstOrDefault().ReportingManagerId;
            foreach (TblRequisitionSkillMapping tblRequisitionSkillMapping in dbContext.TblRequisitionSkillMapping.Where(r => r.RequisitionId == tblRequisition.RequistionId))
            {
                dbContext.TblRequisitionSkillMapping.Remove(tblRequisitionSkillMapping);
            }
            dbContext.SaveChanges();
            tblRequisition.CreatedByNavigation = null;
            foreach (TblRequisitionRecruiterMapping mapping in tblRequisition.TblRequisitionRecruiterMapping)
            {
                mapping.RequisitionId = tblRequisition.RequistionId;
                dbContext.TblRequisitionRecruiterMapping.Add(mapping);
            }
            dbContext.SaveChanges();
            foreach (TblRequisitionSkillMapping mapping in tblRequisition.TblRequisitionSkillMapping)
            {
                TblRequisitionSkillMapping tblRequisitionSkillMapping = new TblRequisitionSkillMapping()
                {
                    RequisitionId = tblRequisition.RequistionId, SkillId = mapping.SkillId
                };
                dbContext.TblRequisitionSkillMapping.Add(tblRequisitionSkillMapping);
            }
            dbContext.SaveChanges();
            if (tblRequisition.Status == RequisitionStatus.Approved)
            {
                tblRequisition.CurrentOwner = String.Join(",", dbContext.TblEmployees.AsNoTracking().Where(r => r.Role.RoleName == RoleConstants.RecruiterLeadRole).Select(t => t.EmployeeName).ToArray());
            }
            if (tblRequisition.Status == RequisitionStatus.AssignedToRecruiter)
            {
                List <long> EmpIds  = tblRequisition.TblRequisitionRecruiterMapping.Select(r => r.EmployeeId).ToList();
                string      EmpName = "";
                foreach (long EmpID in EmpIds)
                {
                    EmpName = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == EmpID).FirstOrDefault().EmployeeName + ",";
                }

                tblRequisition.CurrentOwner = EmpName.Substring(0, EmpName.Length - 1);
            }
            if (tblRequisition.Status == RequisitionStatus.Cancelled)
            {
                tblRequisition.CurrentOwner = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == tblRequisition.CreatedBy).FirstOrDefault().EmployeeName;
            }
            dbContext.Entry(tblRequisition).State = EntityState.Modified;
            dbContext.TblRequisition.Update(tblRequisition);
            int result = dbContext.SaveChanges();

            dbContext.Entry(tblRequisition).State = EntityState.Detached;
            var obj = dbContext.TblRequisition.AsNoTracking().Where(r => r.RequistionId == tblRequisition.RequistionId).Include(r => r.Department).Include(r => r.Designation).Include(r => r.TblRequisitionSkillMapping).FirstOrDefault();

            if (result > 0)
            {
                if (tblRequisition.Status == RequisitionStatus.Approved)
                {
                    SendRequisitionApprovedMail(obj);
                }
                else if (tblRequisition.Status == RequisitionStatus.AssignedToRecruiter)
                {
                    SendRequisitionAssignedMail(obj);
                }
                else if (tblRequisition.Status == RequisitionStatus.CancelRequested)
                {
                    //SendRequisitionCancelRequestMail(obj);
                    SendRequisitionCancelRequestMail(tblRequisition);
                }
                else if (tblRequisition.Status == RequisitionStatus.Cancelled)
                {
                    //SendRequisitionCancellationMail(obj);
                    SendRequestCancellationMail(tblRequisition);
                    RevertInterviewProcess(tblRequisition.RequistionId);
                }
            }
            return(result);
        }
Exemplo n.º 7
0
        public IActionResult CloseRequisition([FromBody] TblRequisition requisition)
        {
            var result = _requisition.CloseRequisition(requisition);

            return(Ok(result));
        }
Exemplo n.º 8
0
 public int CloseRequisition(TblRequisition tblRequisition)
 {
     return(RequisitionDAL.CloseRequisition(tblRequisition));
 }
Exemplo n.º 9
0
 public int UpdateRequisition(TblRequisition tblRequisition)
 {
     return(RequisitionDAL.UpdateRequisition(tblRequisition));
 }
Exemplo n.º 10
0
 public int CreateRequisition(TblRequisition tblRequisition)
 {
     return(RequisitionDAL.CreateRequisition(tblRequisition));
 }