public ActionResult AddCandidate(Candidate Model) { try { Model.RecId = LoginHelper.GetCurrentLoginUser().Id; Model.ResumeSourceId = 1; ATSEntities db = new ATSEntities(); if (Model.CanId > 0) { //edit case //db code for saving date Model.UpdateDate = DateTime.Now; db.Candidates.Attach(Model); db.Entry(Model).State = EntityState.Modified; db.SaveChanges(); } else { //insert case //db code for saving date Model.CreateDate = DateTime.Now; db.Candidates.Add(Model); db.SaveChanges(); } } catch (Exception ex) { string st = ex.Message; } return(RedirectToAction("Sourcing", "Recruiter")); }
public ActionResult AssignToJob(int CandidateId, int JobId) { ATSEntities db = new ATSEntities(); using (db) { var jobObj = db.Jobs.FirstOrDefault(x => x.JobId == JobId); var CandidateObj = db.Candidates.FirstOrDefault(x => x.CanId == CandidateId); CandidateObj.IsActive = false; db.Candidates.Attach(CandidateObj); db.Entry(CandidateObj).State = EntityState.Modified; db.SaveChanges(); if (jobObj != null && CandidateObj != null) { Applicant ApplicantObj = new Applicant(); ApplicantObj.ApplicantFullName = CandidateObj.FirstName + " " + CandidateObj.LastName; ApplicantObj.CanId = CandidateObj.CanId; ApplicantObj.CreateDate = DateTime.Now; ApplicantObj.IsShortlisted = true; ApplicantObj.JobId = jobObj.JobId; db.Applicants.Add(ApplicantObj); db.SaveChanges(); } } return(RedirectToAction("Sourcing", "Recruiter")); }
public ActionResult AddJobs(Job Model) { try { Model.QuestionairId = 1; ATSEntities db = new ATSEntities(); using (db) { if (Model.JobId > 0) { //edit case //db code for saving date Model.UpdateDate = DateTime.Now; db.Jobs.Attach(Model); db.Entry(Model).State = EntityState.Modified; db.SaveChanges(); } else { //insert case //db code for saving date Model.CreateDate = DateTime.Now; db.Jobs.Add(Model); db.SaveChanges(); } } } catch (Exception ex) { string st = ex.Message; } return(RedirectToAction("Jobs", "Recruiter")); }
public ActionResult JobApplicationPage(JobApplicationPageViewModel Model) { int Marks = 0; try { ATSEntities db = new ATSEntities(); using (db) { foreach (var item in Model.AnswerList) { var obj = db.Answers.FirstOrDefault(x => x.AnswerId == item.AnswerId); if (obj.IsRight) { Marks += 1; } } Model.CandidateObj.MarksObtained = Marks; int totalanswer = Model.AnswerList.Count; totalanswer = totalanswer / 2; if (Marks >= totalanswer) { Model.CandidateObj.IsQualified = true; } else { Model.CandidateObj.IsQualified = false; } Model.CandidateObj.ResumeSourceId = 1; Model.CandidateObj.RecId = Model.RecruiterObj.RecId; if (Model.CandidateObj.CanId > 0) { //edit case //db code for saving date Model.CandidateObj.UpdateDate = DateTime.Now; db.Candidates.Attach(Model.CandidateObj); db.Entry(Model.CandidateObj).State = EntityState.Modified; db.SaveChanges(); } else { //insert case //db code for saving date Model.CandidateObj.IsActive = true; Model.CandidateObj.CreateDate = DateTime.Now; db.Candidates.Add(Model.CandidateObj); db.SaveChanges(); } } } catch (Exception ex) { string st = ex.Message; } return(RedirectToAction("JobApplicationPage", "Home", new { Recruiter = Model.RecruiterObj.RecId, Job = Model.JobObj.JobId })); }
public async Task <ActionResult> Edit(Course course) { if (ModelState.IsValid) { db.Entry(course).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction(INDEX_PAGE)); } return(View(course)); }
public ActionResult RecruiterSetting(Recruiter Model, FormCollection fm, HttpPostedFileBase LogoFile) { ATSEntities db = new ATSEntities(); using (db) { if (Model.RecId > 0) { var currentUser = LoginHelper.GetCurrentLoginUser(); Recruiter recruiter = db.Recruiters.FirstOrDefault(x => x.RecId == currentUser.Id); try { //Check if File is available. if (LogoFile != null && LogoFile.ContentLength > 0) { //Save the File. string DirectoryPath = Server.MapPath("~/Content/Images/RecLogo/" + Model.RecId + "/"); string filePath = DirectoryPath + LogoFile.FileName; Model.Logo = LogoFile.FileName; if (!System.IO.Directory.Exists(DirectoryPath)) { System.IO.Directory.CreateDirectory(DirectoryPath); } if (System.IO.Directory.Exists(DirectoryPath)) { LogoFile.SaveAs(filePath); } } } catch (Exception ex) { } recruiter.Username = Model.Username; recruiter.Password = Model.Password; recruiter.CompanyName = Model.CompanyName; recruiter.CompanyAddress = Model.CompanyAddress; recruiter.City = Model.City; recruiter.State = Model.State; recruiter.Logo = Model.Logo; //recruiter.ExternalLogo = Model.ExternalLogo; db.Recruiters.Attach(recruiter); db.Entry(recruiter).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("RecruiterSetting", "Recruiter")); } }
public async Task <ActionResult> Edit([Bind(Include = "ScheduleID,StartTime,EndTime,TeacherID,MinPeople,MaxPeople,CourseID,CourseName,Note,Initiator,CreatedDate,ModifiedBy,ModifiedDate")] Schedule schedule) { schedule.ModifiedDate = DateTime.Now; schedule.CourseName = db.Courses.Where(c => c.CourseID == schedule.CourseID).FirstOrDefault().Name; if (ModelState.IsValid) { db.Entry(schedule).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Name", schedule.CourseID); ViewBag.TeacherID = new SelectList(db.Teachers, "TeacherID", "Name", schedule.TeacherID); return(View(schedule)); }
public ActionResult IsRightAnswers(int QuestionId, int AnswerId, bool Value) { ATSEntities db = new ATSEntities(); using (db) { var Answer = db.Answers.FirstOrDefault(x => x.AnswerId == AnswerId); Answer.IsRight = Value; db.Answers.Attach(Answer); db.Entry(Answer).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Answers", "Recruiter", new { QuestionId = QuestionId })); }
public ActionResult PostJob(int id = 0) { if (id > 0) { Job model = new Job(); ATSEntities db = new ATSEntities(); using (db) { model = db.Jobs.FirstOrDefault(x => x.JobId == id); model.IsPosted = true; model.UpdateDate = DateTime.Now; db.Jobs.Attach(model); db.Entry(model).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Jobs", "Recruiter")); }
public ActionResult AddAnswer(Answer Model) { ATSEntities db = new ATSEntities(); using (db) { if (Model.AnswerId > 0) { //Edit db.Answers.Attach(Model); db.Entry(Model).State = EntityState.Modified; db.SaveChanges(); } else { db.Answers.Add(Model); db.SaveChanges(); } } return(RedirectToAction("Answers", "Recruiter", new { QuestionId = Model.QuestionId })); }
public ActionResult AddQuestions(Question Model) { //Model.QuestionairId = 1; ATSEntities db = new ATSEntities(); using (db) { if (Model.QuestionId > 0) { db.Questions.Attach(Model); db.Entry(Model).State = EntityState.Modified; db.SaveChanges(); } else { db.Questions.Add(Model); db.SaveChanges(); } } return(RedirectToAction("Questions", "Recruiter", new { QuestionairId = Model.QuestionairId })); }
public ActionResult Questioner(Questionair Model) { Model.RecId = LoginHelper.GetCurrentLoginUser().Id; ATSEntities db = new ATSEntities(); using (db) { if (Model.QuestionairId > 0) { db.Questionairs.Attach(Model); db.Entry(Model).State = EntityState.Modified; db.SaveChanges(); } else { db.Questionairs.Add(Model); db.SaveChanges(); } } return(RedirectToAction("Questioner", "Recruiter")); }
public async Task <IHttpActionResult> Put(Guid id, CourseViewModel course) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != course.CourseID) { return(BadRequest()); } Course _course = await db.Courses.FindAsync(id); if (_course == null) { return(NotFound()); } db.Entry(_course).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult CareerPage(CareerPage Model, HttpPostedFileBase LogoFile) { try { if (LogoFile != null && LogoFile.ContentLength > 0) { //Save the File. string DirectoryPath = Server.MapPath("~/Content/Images/ExternalLogo/" + Model.RecId + "/"); string filePath = DirectoryPath + LogoFile.FileName; Model.ExternalLogo = LogoFile.FileName; if (!System.IO.Directory.Exists(DirectoryPath)) { System.IO.Directory.CreateDirectory(DirectoryPath); } if (System.IO.Directory.Exists(DirectoryPath)) { LogoFile.SaveAs(filePath); } } } catch (Exception ex) { } ATSEntities db = new ATSEntities(); using (db) { if (Model.Id == 0) { db.CareerPages.Add(Model); db.SaveChanges(); } else { var DbCareerModel = db.CareerPages.FirstOrDefault(x => x.RecId == Model.RecId); //Check if File is available. if (!string.IsNullOrEmpty(Model.ExternalLogo) && DbCareerModel.ExternalLogo != Model.ExternalLogo) { DbCareerModel.ExternalLogo = Model.ExternalLogo; } if (!string.IsNullOrEmpty(Model.Intro) && DbCareerModel.Intro != Model.Intro) { DbCareerModel.Intro = Model.Intro; } if (!string.IsNullOrEmpty(Model.Description) && DbCareerModel.Description != Model.Description) { DbCareerModel.Description = Model.Description; } if (!string.IsNullOrEmpty(Model.Heading) && DbCareerModel.Heading != Model.Heading) { DbCareerModel.Heading = Model.Heading; } DbCareerModel.UpdateDate = DateTime.Now; db.CareerPages.Attach(DbCareerModel); db.Entry(DbCareerModel).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("CareerPage", "Recruiter")); }
public ActionResult SendEmail(DripEmail Model, int JobId) { ATSEntities db = new ATSEntities(); try { if (Model.IsScheduled == true) { var jobObj = db.Jobs.FirstOrDefault(x => x.JobId == JobId); var ApplicantList = db.Applicants.Where(x => x.JobId == JobId).ToList(); foreach (var item in ApplicantList) { Model.ApplicantId = item.ApplicantId; Model.CandidateId = item.CanId; Model.RecId = LoginHelper.GetCurrentLoginUser().Id; if (jobObj != null && ApplicantList.Count > 0) { //insert case //db code for saving date Model.CreatedDate = DateTime.Now; db.DripEmails.Add(Model); db.SaveChanges(); } } } else { //Save DripEmail var jobObj = db.Jobs.FirstOrDefault(x => x.JobId == JobId); var ApplicantList = db.Applicants.Where(x => x.JobId == JobId).ToList(); foreach (var item in ApplicantList) { Model.ApplicantId = item.ApplicantId; Model.CandidateId = item.CanId; Model.RecId = LoginHelper.GetCurrentLoginUser().Id; if (jobObj != null && ApplicantList.Count > 0) { //insert case //db code for saving date Model.CreatedDate = DateTime.Now; db.DripEmails.Add(Model); db.SaveChanges(); } } //send email Task task = new Task(() => { while (true) { using (db) { var Records = db.DripEmails.Where(x => x.IsScheduled == true && x.ScheduledDateTime <= DateTime.Now && (x.IsSentSuccess == false || x.IsSentSuccess == null)); foreach (var item in Records) { //Email Code here try { int canid = (int)item.CandidateId; var candidate = db.Candidates.FirstOrDefault(x => x.CanId == canid); MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(candidate.Email); mail.Subject = item.Subject; mail.Body = item.EmailBodyText; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("recruiteragentproject", "newproject"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); item.IsSentSuccess = true; //Update Record Code db.DripEmails.Attach(Model); db.Entry(Model).State = EntityState.Modified; db.SaveChanges(); } catch (Exception ex) { ////Update Record Code if error issent=false item update item.IsSentSuccess = false; db.DripEmails.Attach(item); db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } } } Thread.Sleep(1000); } }); task.Start(); } } catch (Exception ex) { string st = ex.Message; } return(RedirectToAction("Campaigns", "Recruiter")); }
protected void Application_Start() { //Code 3 AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Task task = new Task(() => { while (true) { ATSEntities db = new ATSEntities(); using (db) { var Records = db.DripEmails.Where(x => x.IsScheduled == true && x.ScheduledDateTime <= DateTime.Now && (x.IsSentSuccess == false || x.IsSentSuccess == null)).ToList(); foreach (var item in Records) { //Email Code here try { int canId = (int)item.CandidateId; var candiate = db.Candidates.FirstOrDefault(x => x.CanId == canId); MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(candiate.Email);//candidate email mail.Subject = item.Subject; mail.Body = item.EmailBodyText; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("recruiteragentproject", "newproject"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); item.IsSentSuccess = true; //Update Record Code db.DripEmails.Attach(item); db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } catch (Exception ex) { ////Update Record Code if error issent=false item update //Update Record Code item.IsSentSuccess = false; db.DripEmails.Attach(item); db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } } } Thread.Sleep(1000); } }); task.Start(); }