Example #1
0
        public static Candidate GetCandidateById(int candidateId)
        {
            CandidateRepository repository = new CandidateRepository();
            Candidate item = new Candidate();
            item.CandidateId = candidateId;
            item = repository.FindOne(item);
            item.ContactInfo = string.Empty;
            if (!string.IsNullOrEmpty(item.Address))
            {
                item.ContactInfo += "Address : " + item.Address + "/n";
            }
            if (!string.IsNullOrEmpty(item.CVMail))
            {
                item.ContactInfo += "Mail : " + item.CVMail;
            }

            if (item.Inactive.HasValue)
            {
                if(item.Inactive.Value)
                    item.InactiveString = "inactif";
                else
                    item.InactiveString = "actif";
            }

            return item;
        }
    /// <summary>
    /// Save general data of candidate to database.
    /// </summary>
    private Candidate SaveCandidateData()
    {
        if (string.IsNullOrEmpty(txtLastName.Text) || string.IsNullOrEmpty(txtFirstName.Text))
        {
            string message = ResourceManager.GetString("messageCanNameMustNotBeEmpty");
            string script = "<script type=\"text/javascript\">";
            script += " alert(\"" + message + "\")";
            script += " </script>";

            if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
                ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script);
            return null;
        }
        bool isNew = false;
        //Save Candidate
        Candidate candidate = new Candidate();
        if (SessionManager.CurrentCandidate != null)
        {
            candidate = SessionManager.CurrentCandidate;
        }
        else
        {
            isNew = true;
            candidate = new Candidate();
        }
        //Common
        candidate.LastName = txtLastName.Text.Trim();
        candidate.FirstName = txtFirstName.Text.Trim();
        candidate.Unit = ddlUnit.SelectedValue;
        if (!string.IsNullOrEmpty(ddlInterviewer.SelectedValue))
            candidate.Interviewer = ddlInterviewer.SelectedValue;
        else
            candidate.Interviewer = null;
        candidate.DateOfInterView = datDateInterview.SelectedDate;
        candidate.LastModifDate = DateTime.Now;

        //Tab general
        candidate.Address = txtAddress.Text.Trim();
        candidate.ZipCode = txtZip.Text.Trim();
        candidate.City = txtCity.Text.Trim();
        candidate.CountryCode = ddlCountry.SelectedValue;
        candidate.Gender = ddlGenre.SelectedValue;
        if (!string.IsNullOrEmpty(ddlNationality.SelectedValue))
            candidate.Nationlity = ddlNationality.SelectedValue;
        else
            candidate.Nationlity = null;
        candidate.BirthDate = datDateOfBirth.SelectedDate;
        candidate.CreationDate = datCreationDate.SelectedDate;
        if (string.IsNullOrEmpty(ddlStatus.SelectedValue))
            candidate.Inactive = null;
        else
            candidate.Inactive = bool.Parse(ddlStatus.SelectedValue);
        candidate.ReasonDesactivation = txtInactivityReason.Text.Trim();
        candidate.Remark = txtRemarkGeneral.Text.Trim();
        //tab presentation
        if (!string.IsNullOrEmpty(radTabStripCandidateProfile.FindTabByValue("PresentationView").PageViewID))
            candidate.Presentation = txtPresentationText.Text;

        CandidateRepository repo = new CandidateRepository();
        if (isNew)
            repo.Insert(candidate);
        else
            repo.Update(candidate);
        candidate = repo.FindOne(candidate);
        SessionManager.CurrentCandidate = candidate;
        SaveLastViewCandidatesToCookie(candidate);
        if (isNew)
        {
            string script = "<script type='text/javascript'>";
            script += "onSaveOrLoadCandidateProfilePage();";
            script += "</script>";
            if (!ClientScript.IsClientScriptBlockRegistered("onSaveOrLoadCandidateProfilePage"))
                ClientScript.RegisterStartupScript(this.GetType(), "onSaveOrLoadCandidateProfilePage", script);
        }
        return candidate;
    }