private async void SendRequisitionAssignedMail(TblRequisitionStaffing 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.TblRequisitionRecruiterMappingStaffing.Count + 1]; for (int i = 0; tblRequisition.TblRequisitionRecruiterMappingStaffing.Count > i; i++) { TblRequisitionRecruiterMappingStaffing recruiter = tblRequisition.TblRequisitionRecruiterMappingStaffing.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); }
public int CreateRequisitionStaffing(TblRequisitionStaffing tblRequisitionstaffing) { tblRequisitionstaffing.IsActive = true; tblRequisitionstaffing.CreatedDate = DateTime.Now; tblRequisitionstaffing.CreatedBy = CurrentContext.EmployeeID; tblRequisitionstaffing.Status = RequisitionStatus.Open; tblRequisitionstaffing.ManagerEmployeeId = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == CurrentContext.EmployeeID).FirstOrDefault().ReportingManagerId; tblRequisitionstaffing.CurrentOwner = dbContext.TblEmployees.AsNoTracking().Where(r => r.EmployeeId == tblRequisitionstaffing.ManagerEmployeeId).FirstOrDefault().EmployeeName; dbContext.Entry(tblRequisitionstaffing).State = EntityState.Added; dbContext.TblRequisitionStaffing.Add(tblRequisitionstaffing); int result = dbContext.SaveChanges(); dbContext.Entry(tblRequisitionstaffing).State = EntityState.Detached; foreach (TblRequisitionSkillMappingStaffing mapping in tblRequisitionstaffing.TblRequisitionSkillMappingStaffing) { mapping.RequisitionId = tblRequisitionstaffing.RequistionId; dbContext.TblRequisitionSkillMappingStaffing.Add(mapping); } dbContext.SaveChanges(); foreach (TblRequisitionClientContactMappingStaffing mapping in tblRequisitionstaffing.TblRequisitionClientContactMappingStaffing) { mapping.RequisitionId = tblRequisitionstaffing.RequistionId; dbContext.TblRequisitionClientContactMappingStaffing.Add(mapping); } dbContext.SaveChanges(); var obj = dbContext.TblRequisitionStaffing.AsNoTracking().Where(r => r.RequistionId == tblRequisitionstaffing.RequistionId).Include(r => r.Department).Include(r => r.Designation).Include(r => r.TblRequisitionSkillMappingStaffing).FirstOrDefault(); if (result > 0) { SendRequisitionRaisedMail(obj); } dbContext.Entry(obj).State = EntityState.Detached; return(result); }
public int DeleteRequisitionStaffing(int key) { TblRequisitionStaffing tblRequisition = dbContext.TblRequisitionStaffing.Where(e => e.RequistionId == key).FirstOrDefault(); tblRequisition.IsActive = false; dbContext.Entry(tblRequisition).State = EntityState.Modified; dbContext.TblRequisitionStaffing.Update(tblRequisition); dbContext.SaveChanges(); dbContext.Entry(tblRequisition).State = EntityState.Detached; dbContext.TblRequisitionSkillMappingStaffing.RemoveRange(dbContext.TblRequisitionSkillMappingStaffing.Where(r => r.RequisitionId == tblRequisition.RequistionId)); dbContext.SaveChanges(); return(1); }
public int CloseRequisitionStaffing(TblRequisitionStaffing tblRequisition) { tblRequisition.TblRequisitionRecruiterMappingStaffing = null; tblRequisition.TblRequisitionSkillMappingStaffing = null; tblRequisition.ModifiedDate = DateTime.Now; tblRequisition.ModifiedBy = CurrentContext.EmployeeID; tblRequisition.CurrentOwner = "N/A"; dbContext.Entry(tblRequisition).State = EntityState.Modified; dbContext.TblRequisitionStaffing.Update(tblRequisition); int result = dbContext.SaveChanges(); dbContext.Entry(tblRequisition).State = EntityState.Detached; return(result); }
private async void SendRequisitionApprovedMail(TblRequisitionStaffing 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); }
public IActionResult CloseRequisitionStaffing([FromBody] TblRequisitionStaffing requisition) { var result = _requisitionstaffing.CloseRequisitionStaffing(requisition); return(Ok(result)); }
public int CloseRequisitionStaffing(TblRequisitionStaffing tblRequisition) { return(RequisitionStaffingDAL.CloseRequisitionStaffing(tblRequisition)); }
//public List<TblRequisitionStaffing> GetAllRequisitionStaffing(bool IsCancelled = true) //{ // var result = new List<TblRequisitionStaffing>(); // result = RequisitionStaffingDAL.GetAllRequisitionStaffing(IsCancelled); // return result; //} public int UpdateRequisitionStaffing(TblRequisitionStaffing tblRequisition) { return(RequisitionStaffingDAL.UpdateRequisitionStaffing(tblRequisition)); }
public int UpdateRequisitionStaffing(TblRequisitionStaffing 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 (TblRequisitionSkillMappingStaffing TblRequisitionSkillMappingStaffing in dbContext.TblRequisitionSkillMappingStaffing.Where(r => r.RequisitionId == tblRequisition.RequistionId)) { dbContext.TblRequisitionSkillMappingStaffing.Remove(TblRequisitionSkillMappingStaffing); } dbContext.SaveChanges(); foreach (TblRequisitionClientContactMappingStaffing tblRequisitionClientContactMappingStaffing in dbContext.TblRequisitionClientContactMappingStaffing.Where(r => r.RequisitionId == tblRequisition.RequistionId)) { dbContext.TblRequisitionClientContactMappingStaffing.Remove(tblRequisitionClientContactMappingStaffing); } dbContext.SaveChanges(); tblRequisition.CreatedByNavigation = null; foreach (TblRequisitionRecruiterMappingStaffing mapping in tblRequisition.TblRequisitionRecruiterMappingStaffing) { mapping.RequisitionId = tblRequisition.RequistionId; dbContext.TblRequisitionRecruiterMappingStaffing.Add(mapping); } dbContext.SaveChanges(); foreach (TblRequisitionSkillMappingStaffing mapping in tblRequisition.TblRequisitionSkillMappingStaffing) { TblRequisitionSkillMappingStaffing tblRequisitionSkillMapping = new TblRequisitionSkillMappingStaffing() { RequisitionId = tblRequisition.RequistionId, SkillId = mapping.SkillId }; dbContext.TblRequisitionSkillMappingStaffing.Add(tblRequisitionSkillMapping); } dbContext.SaveChanges(); foreach (TblRequisitionClientContactMappingStaffing mapping in tblRequisition.TblRequisitionClientContactMappingStaffing) { TblRequisitionClientContactMappingStaffing tblRequisitionClientContactMapping = new TblRequisitionClientContactMappingStaffing() { RequisitionId = tblRequisition.RequistionId, ContactId = mapping.ContactId }; dbContext.TblRequisitionClientContactMappingStaffing.Add(tblRequisitionClientContactMapping); } dbContext.SaveChanges(); if (tblRequisition.Status == RequisitionStatus.Approved) { tblRequisition.CurrentOwner = String.Join(",", dbContext.TblEmployees.AsNoTracking().Where(r => r.Role.RoleName == RoleConstants.StaffingLeadRole).Select(t => t.EmployeeName).ToArray()); } if (tblRequisition.Status == RequisitionStatus.AssignedToStaffing) { List <long> EmpIds = tblRequisition.TblRequisitionRecruiterMappingStaffing.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.TblRequisitionStaffing.Update(tblRequisition); int result = dbContext.SaveChanges(); dbContext.Entry(tblRequisition).State = EntityState.Detached; var obj = dbContext.TblRequisitionStaffing.AsNoTracking().Where(r => r.RequistionId == tblRequisition.RequistionId).Include(r => r.Department).Include(r => r.Designation).Include(r => r.TblRequisitionSkillMappingStaffing).FirstOrDefault(); if (result > 0) { if (tblRequisition.Status == RequisitionStatus.Approved) { SendRequisitionApprovedMail(obj); } else if (tblRequisition.Status == RequisitionStatus.AssignedToStaffing) { 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); }