public ActionResult Create([Bind(Include = "Id_candidate,Last_name,First_name,Email,Phone,Address,City,Country,AboutMe")] CandidateProfile candidateProfile) { if (ModelState.IsValid) { db.CandidateProfiles.Add(candidateProfile); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(candidateProfile)); }
//delete saved candidate public JsonResult DeleteSavedCandidate(int?Id_SavedCandidate) { SavedCandidate savedCandidate = db.SavedCandidates.Find(Id_SavedCandidate); bool result = false; if (savedCandidate != null) { db.SavedCandidates.Remove(savedCandidate); db.SaveChanges(); result = true; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult ResetPassword(ResetPasswordModel model) { var message = ""; if (ModelState.IsValid) { using (NoBordersDB db = new NoBordersDB()) { var user = db.Users.Where(a => a.reset_password_code == model.ResetCode).FirstOrDefault(); if (user != null) { user.password = /*Crypto.Hash(*/ model.NewPassword; user.reset_password_code = ""; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); message = "New password updated successfully"; } } } else { message = "Something invalid"; return(View()); } ViewBag.Message = message; return(View(model)); }
public ActionResult ForgotPassword(string email) { //check if the email is valid //generate reset password link //sent email string message = ""; using (NoBordersDB db = new NoBordersDB()) { var account = db.Users.Where(x => x.email == email).FirstOrDefault(); if (account != null) { //send email for reset password string resetCode = Guid.NewGuid().ToString(); SendVerificationLinkEmail(account.email, resetCode); account.reset_password_code = resetCode; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); message = "Reset password link has been sent to your email."; } else { message = "This is not a register email, please check again."; } } ViewBag.Message = message; return(View()); }
//add language public JsonResult AddLanguage(int?Id_candidate, string language, string language_level) { CandidateLanguages candidateLanguages = new CandidateLanguages(); bool result = false; candidateLanguages.id_candidate = (int)Id_candidate; candidateLanguages.language = language; candidateLanguages.language_level = language_level; db.CandidateLanguages.Add(candidateLanguages); db.SaveChanges(); result = true; return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult UserProfile(CandidateProfile candidateProfile) { NoBordersDB db = new NoBordersDB(); ModelState.Clear(); if (ModelState.IsValid) { //update candidate contact data db.Entry(candidateProfile).State = System.Data.Entity.EntityState.Modified; Session["user_name"] = candidateProfile.First_name + " " + candidateProfile.Last_name; //loop through every candidate experience and update in database //for (int i = 0; i < candidateProfile.CandidateExperience.Count(); i++) //{ // db.Entry(candidateProfile.CandidateExperience[i]).State = System.Data.Entity.EntityState.Modified; //} ////loop through every candidate studies and update in database //for (int i = 0; i < candidateProfile.CandidateStudies.Count(); i++) //{ // db.Entry(candidateProfile.CandidateStudies[i]).State = System.Data.Entity.EntityState.Modified; //} ////loop through every candidate tech and update in database //for (int i = 0; i < candidateProfile.CandidateTechnologies.Count(); i++) //{ // db.Entry(candidateProfile.CandidateTechnologies[i]).State = System.Data.Entity.EntityState.Modified; //} ////loop through every candidate languages and update in database //for (int i = 0; i < candidateProfile.CandidateLanguages.Count(); i++) //{ // db.Entry(candidateProfile.CandidateLanguages[i]).State = System.Data.Entity.EntityState.Modified; //} //perform the update in all the tables try { db.SaveChanges(); } catch (DbUpdateException ex) { string error = ex.Message; } return(RedirectToAction("UserProfile")); } return(View(candidateProfile)); }
//remove experience row public JsonResult DeleteExperience(int?Id_candidate, int?Id_experience) { NoBordersDB db = new NoBordersDB(); CandidateProfile candidateProfile = db.CandidateProfiles.Find(Id_candidate); CandidateExperience candidateExperience = db.CandidateExperiences.SingleOrDefault(x => x.Id_candidate == Id_candidate && x.Id_experience == Id_experience); bool result = false; if (candidateExperience != null) { db.CandidateExperiences.Remove(candidateExperience); db.SaveChanges(); result = true; } return(Json(result, JsonRequestBehavior.AllowGet)); }
//remove studies row public JsonResult DeleteStudies(int?Id_candidate, int?id_education) { NoBordersDB db = new NoBordersDB(); CandidateProfile candidateProfile = db.CandidateProfiles.Find(Id_candidate); CandidateStudies candidateStudies = db.CandidateStudies.SingleOrDefault(x => x.id_candidate == Id_candidate && x.id_education == id_education); bool result = false; if (candidateStudies != null) { db.CandidateStudies.Remove(candidateStudies); db.SaveChanges(); result = true; } return(Json(result, JsonRequestBehavior.AllowGet)); }
//mark a candidate = saved public JsonResult SaveProfile(int?Id_candidate) { bool result = false; if (Id_candidate != null) { ModelState.Clear(); NoBordersDB db = new NoBordersDB(); var candidate = db.CandidateProfiles.Single(cand => cand.Id_candidate == Id_candidate); //get the list of all the experiences for the logged in user candidate.CandidateExperience = db.CandidateExperiences.Where(x => x.Id_candidate == Id_candidate).ToList(); //get the list of all the studies for the logged user candidate.CandidateStudies = db.CandidateStudies.Where(x => x.id_candidate == Id_candidate).ToList(); //get the list of all the technologies for the logged user candidate.CandidateTechnologies = db.CandidateTechnologies.Where(x => x.id_candidate == Id_candidate).ToList(); //get the list of all the languages for the logged user candidate.CandidateLanguages = db.CandidateLanguages.Where(x => x.id_candidate == Id_candidate).ToList(); SavedCandidate savedCandidate = new SavedCandidate(); //retrieve the email of the logged in recruiter string recruiterEmail = (string)Session["recruiter_email"]; var checkemail = db.SavedCandidates.FirstOrDefault(x => x.Email == candidate.Email && x.Recruiter_email == recruiterEmail); //check if the candidate is allready saved if (checkemail == null) { savedCandidate.Email = candidate.Email; savedCandidate.First_name = candidate.First_name; savedCandidate.Last_name = candidate.Last_name; savedCandidate.Country_to_work = candidate.Country_To_Work; savedCandidate.Status = candidate.Interest; savedCandidate.Recruiter_email = Session["recruiter_email"].ToString(); savedCandidate.Process = ""; List <CandidateTechnologies> skills = candidate.CandidateTechnologies.Where(x => x.tech_level == "Senior ").ToList(); if (skills.Count == 0) { skills = candidate.CandidateTechnologies.Where(x => x.tech_level == "Middle ").ToList(); if (skills.Count == 0) { skills = candidate.CandidateTechnologies.Where(x => x.tech_level == "Junior ").ToList(); if (skills.Count == 0) { savedCandidate.Skill = "N/A"; savedCandidate.Experience = "N/A"; } else { savedCandidate.Skill = skills[0].tech_name; savedCandidate.Experience = skills[0].tech_level; } } else { savedCandidate.Skill = skills[0].tech_name; savedCandidate.Experience = skills[0].tech_level; } } else { savedCandidate.Skill = skills[0].tech_name; savedCandidate.Experience = skills[0].tech_level; } db.SavedCandidates.Add(savedCandidate); db.SaveChanges(); result = true; return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(result, JsonRequestBehavior.AllowGet)); }