public static void AddEducationDetails(CandidateModel candidate)
        {
            SqlConnection con = DBUtils.getDBConnection();
            con.Open();

            candidate.newUgQualification = getQualificationsNameToId()[candidate.newUgQualification];
            candidate.newPgQualification = getQualificationsNameToId()[candidate.newPgQualification];

            String query = "";

            string graduation ="";
            string postGraduation = "";
            SqlCommand command = new SqlCommand("select graduation, post_graduation from dbo.Applicant where candidate_id = " + candidate.user_id + ";" , con);
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                try
                {
                    graduation = reader.GetString(0);
                }
                catch (Exception)
                {
                    graduation = "";
                }

                try
                {
                    postGraduation = reader.GetString(1);
                }
                catch (Exception)
                {
                    postGraduation = "";
                }
            }

            reader.Close();

            if (graduation.Equals("") && !candidate.newUgQualification.Equals("0"))
            {
                graduation = candidate.newUgQualification;
            }
            else if (!graduation.Equals("") && !candidate.newUgQualification.Equals("0"))
            {
                graduation += "," + candidate.newUgQualification;
            }

            if (postGraduation.Equals("") && !candidate.newPgQualification.Equals("0"))
            {
                postGraduation = candidate.newPgQualification;
            }
            else if (!postGraduation.Equals("") && !candidate.newPgQualification.Equals("0"))
            {
                postGraduation += "," + candidate.newPgQualification;
            }

            query = "update dbo.Applicant set " + "graduation = '" + graduation + "'" +
                ", " + "post_graduation = '" + postGraduation + "'" + " where candidate_id = " + candidate.user_id;

            command = new SqlCommand(query, con);
            command.ExecuteNonQuery();
            con.Close();
        }
        public static void UpdatePersonalInfo(CandidateModel can)
        {
            SqlConnection con = DBUtils.getDBConnection();
            con.Open();

            SqlCommand command = new SqlCommand("update dbo.Applicant set address = '" + can.Address + "', " +
                "contact_num = '" + can.ContactNo + "', email_id = '" + can.EmailID + "' where candidate_id = " + can.user_id, con);

            command.ExecuteNonQuery();
            con.Close();
        }
        public static CandidateModel GetCandidateDetails(int userId)
        {
            SqlConnection con = DBUtils.getDBConnection();
            con.Open();

            SqlCommand command = new SqlCommand("select candidate_id, name, email_id, contact_num, gender, dob, address," +
                " graduation, post_graduation from dbo.Applicant where candidate_id=" + userId + ";", con);
            SqlDataReader reader = command.ExecuteReader();

            CandidateModel can = new CandidateModel();
            if (reader == null || !reader.Read())
            {
                return null;
            }
            can.user_id = Convert.ToInt32(reader[0]);
            can.Name = Convert.ToString(reader[1]);
            can.EmailID = Convert.ToString(reader[2]);
            can.ContactNo = Convert.ToString(reader[3]);
            can.gender = Convert.ToString(reader[4]);
            can.dob = Convert.ToDateTime(reader[5]);
            can.Address = Convert.ToString(reader[6]);

            String[] ugList = Convert.ToString(reader[7]).Split(',');
            can.ugQualifications = new List<string>();
            foreach (var item in ugList)
            {
                if(item.Length > 0)
                can.ugQualifications.Add(item);
            }

            String[] pgList = Convert.ToString(reader[8]).Split(',');
            can.pgQualifications = new List<string>();
            foreach (var item in pgList)
            {
                if (item.Length > 0)
                can.pgQualifications.Add(item);
            }

            con.Close();
            return can;
        }
        public ActionResult ViewJobDetails()
        {
            if (!Navigator.IsUserLoggedIn(Session))
            {
                @ViewBag.Message = "Sorry! You need to login to view this page.";
                return View("Message");
                //return RedirectToAction("Login", "Account");
            }
            else if (!Navigator.UserRoleValidation(Session, "candidate"))
            {
                @ViewBag.Message = "Access Denied !   You are not allowed to visit this page.";
                return View("Message");
                //return RedirectToAction("Login", "Account");
            }

            User user = (User)Session["user"];

            CandidateModel candidate = new CandidateModel();
            candidate = CandidateDAL.GetCandidateDetails(user.user_id);
            candidate.experienceDetails = CandidateDAL.GetCandidateExperienceDetails(user.user_id);

            int totalExperience = 0;
            foreach (var item in candidate.experienceDetails)
            {
                totalExperience += item.experience;
            }

            JobViewModel jobViewModel = new JobViewModel();
            jobViewModel.jobs = CandidateDAL.GetApplicableJobs(user.user_id);;
            jobViewModel.qualifications = CandidateDAL.GetQualificationsIdToName();
            jobViewModel.candidateUgQualification = candidate.ugQualifications;
            jobViewModel.candidatePgQualification = candidate.pgQualifications;
            jobViewModel.totalExperience = totalExperience;
            jobViewModel.jobsAlreadyApplied = CandidateDAL.GetNumJobsAppliedFor(user.user_id);
            jobViewModel.appliedJobs = CandidateDAL.GetAppliedJobs(user.user_id);

            return View(jobViewModel);
        }
 public string UpdateQualificationDetails(CandidateModel candidate)
 {
     CandidateDAL.AddEducationDetails(candidate);
     return "";
 }
        public ActionResult UpdateProfile()
        {
            if (!Navigator.IsUserLoggedIn(Session))
            {
                @ViewBag.Message = "Sorry! You need to login to view this page.";
                return View("Message");
                //return RedirectToAction("Login", "Account");
            }
            else if (!Navigator.UserRoleValidation(Session, "candidate"))
            {
                @ViewBag.Message = "Access Denied !   You are not allowed to visit this page.";
                return View("Message");
                //return RedirectToAction("Login", "Account");
            }

            CandidateModel candidate = new CandidateModel();

            int user_id = ((User)Session["user"]).user_id;
            candidate = CandidateDAL.GetCandidateDetails(user_id);
            candidate.experienceDetails = CandidateDAL.GetCandidateExperienceDetails(user_id);

            List<QualificationModel> qualifications = CandidateDAL.GetQualificationDetails();
            List<SelectListItem> ugQualifications = new List<SelectListItem>();
            List<SelectListItem> pgQualifications = new List<SelectListItem>();

            ugQualifications.Add(new SelectListItem { Selected = true, Text = "<-Select->", Value = "0" });
            pgQualifications.Add(new SelectListItem { Selected = true, Text = "<-Select->", Value = "0" });

            foreach (var item in qualifications)
            {
                if (candidate.ugQualifications.Contains(Convert.ToString(item.qualification_id)))
                    continue;

                if (candidate.pgQualifications.Contains(Convert.ToString(item.qualification_id)))
                    continue;

                if (item.type.Equals("UG"))
                    ugQualifications.Add(new SelectListItem { Text = item.qualification, Value = item.qualification });
                else
                    pgQualifications.Add(new SelectListItem { Text = item.qualification, Value = item.qualification });
            }

            ViewBag.ugListData = ugQualifications;
            ViewBag.pgListData = pgQualifications;
            return View(candidate);
        }
 public string UpdatePersonalInfo(CandidateModel candidate)
 {
     CandidateDAL.UpdatePersonalInfo(candidate);
     return "";
 }