예제 #1
0
        public ActionResult RegisterCandidate(CandidateRegister candidate)
        {
            NoBordersDB db        = new NoBordersDB();
            var         checkmail = db.Users.SingleOrDefault(x => x.email == candidate.email);
            string      message   = "";

            //check if email is allready created
            if (checkmail == null)
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        //calling stored procedure
                        CandidateRegisterDL candDL = new CandidateRegisterDL();
                        candDL.registerCandidate(candidate);

                        var user = db.CandidateProfiles.Single(x => x.Email == candidate.email);
                        Session["candidate_id"] = user.Id_candidate;
                        Session["user_name"]    = user.First_name + " " + user.Last_name;
                        return(RedirectToAction("userProfile", "user"));
                    }
                    return(View());
                }
                catch
                {
                    return(View());
                }
            }
            message         = "This address is allready in use,please insert other email.";
            ViewBag.Message = message;
            return(View());
        }
예제 #2
0
        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));
        }
예제 #3
0
        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());
        }
예제 #4
0
        // GET:UserDetails
        public ActionResult UserProfile()
        {
            NoBordersDB db          = new NoBordersDB();
            int         candidateId = Convert.ToInt32(Session["candidate_id"]);

            try
            {
                //get contact data details for logged in user
                var candidate = db.CandidateProfiles.Single(cand => cand.Id_candidate == candidateId);

                //get the list of all the experiences for the logged in user
                candidate.CandidateExperience = db.CandidateExperiences.Where(x => x.Id_candidate == candidateId).ToList();
                //get the list of all the studies for the logged user
                candidate.CandidateStudies = db.CandidateStudies.Where(x => x.id_candidate == candidateId).ToList();
                //get the list of all the technologies for the logged user
                candidate.CandidateTechnologies = db.CandidateTechnologies.Where(x => x.id_candidate == candidateId).ToList();
                //get the list of all the languages for the logged user
                candidate.CandidateLanguages = db.CandidateLanguages.Where(x => x.id_candidate == candidateId).ToList();


                return(View(candidate));
            }

            catch (Exception ex)
            {
                string error = ex.Message;
                return(RedirectToAction("Login", "Login"));
            }
        }
예제 #5
0
        public ActionResult RegisterCompany(CompanyRegister company)
        {
            NoBordersDB db        = new NoBordersDB();
            var         checkmail = db.Users.SingleOrDefault(x => x.email == company.email);

            //check if email is allready created
            if (checkmail == null)
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        RecruiterRegisterDL recruiterDL = new RecruiterRegisterDL();
                        recruiterDL.registerRecruiter(company);
                        Session["Recruiter_email"] = company.email;
                        return(RedirectToAction("CandidatesList", "Candidates"));
                    }
                    return(View());
                }
                catch
                {
                    return(View());
                }
            }
            return(View());
        }
예제 #6
0
        //load saved candidates list
        public ActionResult SavedCandidates()
        {
            NoBordersDB           db = new NoBordersDB();
            List <SavedCandidate> savedCandidates;
            string recruiter = "";

            if (string.IsNullOrEmpty((string)Session["Recruiter_email"]))
            {
                return(RedirectToAction("Login", "Login"));
            }
            else
            {
                recruiter       = Session["Recruiter_email"].ToString();
                savedCandidates = db.SavedCandidates.Where(x => x.Recruiter_email == recruiter).ToList();
                return(View(savedCandidates));
            }
        }
예제 #7
0
        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));
        }
예제 #8
0
        //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));
        }
예제 #9
0
        //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));
        }
예제 #10
0
        public ActionResult Login(UserBus userBus, UserModel user)
        {
            if (ModelState.IsValid)
            {
                if (userBus.IsValid(user.email, user.password, user.userTypeId))
                {
                    CandidateProfileDL candDl = new CandidateProfileDL();
                    NoBordersDB        db     = new NoBordersDB();

                    //checking the user type ( candidate/recruiter)
                    var ut = userBus.userTypeId(user.email, user.password);
                    if (ut == 1)
                    {
                        //storing logged -in user id in session variable
                        var id = candDl.getCandidateId(user.email);
                        Session["candidate_id"] = id;


                        //getting logged in user details
                        var dummyModel = db.CandidateProfiles.SingleOrDefault(cand => cand.Id_candidate == id);

                        //getting the full name of the logged in user to be displayed on the UserProfile page
                        Session["user_name"] = dummyModel.First_name + " " + dummyModel.Last_name;

                        Membership.ValidateUser(user.email, user.password);
                        return(RedirectToAction("UserProfile", "User"));
                    }
                    else if (ut == 2)
                    {
                        Session["recruiter_email"] = user.email;
                        return(RedirectToAction("CandidatesList", "Candidates"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Login data is incorrect!");
                }
            }
            return(View(user));
        }
예제 #11
0
        public ActionResult ResetPassword(string id)
        {
            //verify the reset password link
            //find account associated with the link
            //redirect to reset password page


            using (NoBordersDB db = new NoBordersDB())
            {
                var user = db.Users.Where(x => x.reset_password_code == id).FirstOrDefault();

                if (user != null)
                {
                    ResetPasswordModel model = new ResetPasswordModel();
                    model.ResetCode = id;
                    return(View(model));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
        }
예제 #12
0
        //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));
        }