//Saving TO orion Comm public string saveToOrionComm(int[][] searchmodel, string jobid) { //long jobid = Convert.ToInt64((searchmodel["jobid"].ToString())); string result = "no"; try { long jid = Convert.ToInt32(jobid); int rowcount = 0; if (searchmodel != null) { rowcount = searchmodel.Count(); } qendidateListInJob newjoblist = new qendidateListInJob(); for (long i = 0; i < rowcount; i++) { long qenid = Convert.ToInt16(searchmodel[i][0]); int catid = Convert.ToInt16(searchmodel[i][1]); if (catid != 0) { var qenExists = db.qendidateListInJobs.Where(e => e.qenID == qenid && e.jobID == jid).FirstOrDefault(); if (qenExists == null) { newjoblist.qenID = qenid; newjoblist.category = catid; newjoblist.jobID = jid; db.qendidateListInJobs.Add(newjoblist); db.SaveChanges(); } else { qenExists.category = catid; db.Entry(qenExists).State = EntityState.Modified; db.SaveChanges(); } } result = jid.ToString(); } } catch (Exception e) { BaseUtil.CaptureErrorValues(e); } return(result); }
public async Task <string> Apply(Int32?jobID) { try { var candidateID = BaseUtil.GetSessionValue(AdminInfo.UserID.ToString()); if (candidateID == "" || candidateID == null) { return("login"); } int roleID = Convert.ToInt32(BaseUtil.GetSessionValue(AdminInfo.role_id.ToString())); long qenID = Convert.ToInt32(candidateID); var email = BaseUtil.GetSessionValue(AdminInfo.LoginID.ToString()); if (roleID == 5) { qenAppliedJob oqenAppliedJob = new qenAppliedJob(); if (!db.qenAppliedJobs.Any(e => e.jobID == jobID && e.qenID == qenID)) { oqenAppliedJob.jobID = (long)jobID; oqenAppliedJob.qenID = qenID; oqenAppliedJob.appliedDate = BaseUtil.GetCurrentDateTime(); oqenAppliedJob.dataIsCreated = BaseUtil.GetCurrentDateTime(); oqenAppliedJob.dataIsUpdated = BaseUtil.GetCurrentDateTime(); oqenAppliedJob.isActive = true; oqenAppliedJob.isDelete = false; oqenAppliedJob.App_status_id = 1; db.qenAppliedJobs.Add(oqenAppliedJob); db.SaveChanges(); if (!db.qendidateListInJobs.Any(e => e.jobID == jobID && e.qenID == qenID)) { qendidateListInJob oqendidateListInJobs = new qendidateListInJob(); oqendidateListInJobs.category = 0; oqendidateListInJobs.jobID = (long)jobID; oqendidateListInJobs.qenID = qenID; oqendidateListInJobs.SelfApplied = true; db.qendidateListInJobs.Add(oqendidateListInJobs); db.SaveChanges(); } else { qendidateListInJob oqendidateListInJobs = new qendidateListInJob(); oqendidateListInJobs = db.qendidateListInJobs.Where(e => e.jobID == jobID && e.qenID == qenID).FirstOrDefault(); oqendidateListInJobs.SelfApplied = true; db.Entry(oqendidateListInJobs).State = EntityState.Modified; db.SaveChanges(); } //----------------------------use below code to send emailer------------------------------------------------------------ string jobUrl = "https://spotaneedle.com/jobDetails/JobView?jobID=" + BaseUtil.encrypt(jobID.ToString()); StreamReader sr = new StreamReader(Server.MapPath("/Emailer/jobAppliedSuccessfully.html")); string HTML_Body = sr.ReadToEnd(); string final_Html_Body = HTML_Body.Replace("#name", BaseUtil.GetSessionValue(AdminInfo.FullName.ToString())).Replace("#url", jobUrl); sr.Close(); string To = email.ToString(); string mail_Subject = "Thank you for appling job"; string result = BaseUtil.sendEmailer(To, mail_Subject, final_Html_Body, ""); //----------------------------end to send emailer------------------------------------------------------------ return("mail sent and applied"); } else { return("alreadyApplied"); } } else { return("access"); //"Don't have this access."; } } catch (Exception e) { BaseUtil.CaptureErrorValues(e); } return("login"); }