public void Delete(VacancyApplicant vacancyApplicant)
 {
     _context.VacancyApplicants.Remove(vacancyApplicant);
 }
 public async Task Create(VacancyApplicant vacancyApplicant)
 {
     await _context.VacancyApplicants.AddAsync(vacancyApplicant);
 }
    protected void btnRegExtrenal_Click(object sender, EventArgs e)
    {
        clearlabels();

        bool isAllValidate = true;
        string FirstName = null;
        string MiddleName = null;
        string currentBranch = null;
        string Jobtitle = null;
        string JGrade = null;
        string vacancyInfo = null;
        string EduLevel = null;
        string qualification = null;

        if (txtOtherEmpID.Text != "")
        {
            Employee employee = new Employee();
            employee.EmpID = txtOtherEmpID.Text;

            EmployeeManager employeeManager = new EmployeeManager(employee);
            isAllValidate = !(employeeManager.isEmployeeAlreadyExist());

            //TODO, display about the duplicate warning  message getting from TransactionResponse
            //This method should not return boolean but TransactionResponse containing a boolean about the duplicate !!! 
            if (!isAllValidate)
            {
                msgPanel.Visible = true;
                String districtName = (String)PageAccessManager.getDistrictSettingValue(PageConstants.DISTRCT_NAME).Data;

                ErroroDIV.Visible = true;
                lblErrorMsg.Text = DBOperationErrorConstants.M_EMPLOYEE_ALREAD_IEXISTS + " in " +  districtName;
                isAllValidate = false;
                //No need to continue, we canstop the flow here. 
                return;
            }
        }
        else
        {
            isAllValidate = false;
            lblOtherEmp.Visible = true;
        }

        if (txtOtherFName.Text != "")
        {
            FirstName = txtOtherFName.Text;
        }
        else
        {
            isAllValidate = false;
            lblOtherFName.Visible = true;
        }

        if (txtOtherMName.Text != "")
        {
            MiddleName = txtOtherMName.Text;
        }
        else
        {
            isAllValidate = false;
            lblOtherMName.Visible = true;
        }

        if (DropDownOtherbranch.SelectedValue != "-1")
        {
            currentBranch = DropDownOtherbranch.SelectedValue;
        }
        else
        {
            isAllValidate = false;
            lblOtherBranch.Visible = true;
        }

        if (txtOtherJobtitle.Text != "")
        {
            Jobtitle = txtOtherJobtitle.Text;
        }
        else
        {
            isAllValidate = false;
            lblOtherJTitle.Visible = true;
        }

        if (DropDownOtherJGrade.SelectedValue != "-1")
        {
            JGrade = DropDownOtherJGrade.SelectedValue;
        }
        else
        {
            isAllValidate = false;
            lblOtherJGrade.Visible = true;
        }

        if (DropDownOtherVacancyNo.SelectedValue != "-1")
        {
            vacancyInfo = DropDownOtherVacancyNo.SelectedValue;
        }
        else
        {
            isAllValidate = false;
            lblOtherVacNo.Visible = true;
        }

        if (DropDownOthereduLevel.SelectedValue != "-1")
        {
            EduLevel = DropDownOthereduLevel.SelectedValue;
        }
        else
        {
            isAllValidate = false;
            lblOtherELevel.Visible = true;
        }

        if (txtOtherQual.Text != "")
        {
            qualification = txtOtherQual.Text;
        }
        else
        {
            isAllValidate = false;
            lblOtherQualification.Visible = true;
        }

        if (!isAllValidate)
        {
            return;
        }

        string[] splitter = new string[] { ">>" };

        string[] VacancyInfoTosplit = vacancyInfo.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
        string vacancyNo = VacancyInfoTosplit[0];
        string VacancyDate = VacancyInfoTosplit[1];

        VacancyApplicant vacancyAppilcant = new VacancyApplicant();

        vacancyAppilcant.EmpId = txtOtherEmpID.Text;
        vacancyAppilcant.FirstName = FirstName;
        vacancyAppilcant.MiddleName = MiddleName;
        vacancyAppilcant.LastName = txtOtherLName.Text;

        vacancyAppilcant.CurrentBranch = currentBranch;
        vacancyAppilcant.JobTitle = txtOtherJobtitle.Text;
        vacancyAppilcant.CurrentJGrade = JGrade;
        vacancyAppilcant.VacancyNo = vacancyNo;
        vacancyAppilcant.VacancyDate = VacancyDate;
        vacancyAppilcant.EducLevel = EduLevel;
        vacancyAppilcant.Qualification = qualification;

        VacancyRegistrationAndEvaluationManager vacancyRegEvaluationManager = new VacancyRegistrationAndEvaluationManager(vacancyAppilcant);
        TransactionResponse response = vacancyRegEvaluationManager.registerApplicants(false, false); 

        if (response.isSuccessful())
        {
            msgPanel.Visible = true;
            SucessDIV.Visible = true;
            lblSuccessMessage.Text = response.getMessage();
            btnRegExtrenal.Visible = false;
            btnCancelExtrenal.Visible = true;
        }
        else
        {
            msgPanel.Visible = true;
            ErroroDIV.Visible = true;
            lblErrorMsg.Text = response.getErrorCode() + response.getMessage();
            btnRegExtrenal.Visible = false;
            btnCancelExtrenal.Visible = true;
        }
    }
 public VacancyRegistrationAndEvaluationManager(VacancyApplicant vacancyApplicant)
 {
     this.vacancyApplicant = vacancyApplicant;
 }
    protected void btnRegInternal_Click(object sender, EventArgs e)
    {
        //clear Validation Message 
        clearlabels();

        bool trackAll = true;
        string vacancyInfo = null;
        string eduLevel = null;
        string qualification = null;

        if (DropDownVacancyNo.SelectedValue != "-1")
        {
            vacancyInfo = DropDownVacancyNo.SelectedValue;
        }
        else
        {
            trackAll = false;
            lblVacNo.Visible = true;
        }

        if (trackEduLevel)
        {
            if (DropDownEduLevel.SelectedValue != "-1")
            {
                eduLevel = DropDownEduLevel.SelectedValue;
            }
            else
            {
                trackAll = false;
                lblEduc.Visible = true;
            }
        }
        else
        {
            eduLevel = DropDownListEduLevDB.SelectedValue;
        }

        if (trackQualification)
        {
            if (txtQualif.Text != "")
            {
                qualification = txtQualif.Text;
            }
            else
            {
                trackAll = false;
                lblQualif.Visible = true;
            }
        }
        else
        {
            qualification = DropDownListDBQual.SelectedValue;
        }

        if (!trackAll)
        {
            return;
        }

        //Check Employee In recently selected and penality table

        bool checkPromo = checkPromotedEmployee();
        bool checkRemark = checkEmployeeRemark();

        if (!checkPromo || !checkRemark)
        {
            btnRegInternal.Visible = false;
            btnCancelIntrenal.Visible = true;
            return;
        }
        else
        {
            string[] splitter = new string[] { ">>" };

            string[] VacancyInfoTosplit = vacancyInfo.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
            string vacancyNo = VacancyInfoTosplit[0];
            string VacancyDate = VacancyInfoTosplit[1];
            VacancyApplicant vacancyAppilcant = new VacancyApplicant();

            vacancyAppilcant.EmpId = txtWAADEmpID.Text;
            vacancyAppilcant.VacancyNo = vacancyNo;
            vacancyAppilcant.VacancyDate = VacancyDate;

            vacancyAppilcant.EducLevel = eduLevel;
            vacancyAppilcant.Qualification = qualification;

            VacancyRegistrationAndEvaluationManager vacRegisterManager = new VacancyRegistrationAndEvaluationManager(vacancyAppilcant);
            TransactionResponse response = vacRegisterManager.registerApplicants(true, (!isEduQualExist));

            if (response.isSuccessful())
            {
                clearMsgPanel();
                msgPanel.Visible = true;
                SucessDIV.Visible = true;
                lblSuccessMessage.Text = response.getMessage();
                btnRegInternal.Visible = false;
                btnCancelIntrenal.Visible = true;
            }
            else
            {
                clearMsgPanel();
                msgPanel.Visible = true;
                ErroroDIV.Visible = true;
                lblErrorMsg.Text = response.getErrorCode() + response.getMessage();
                btnRegInternal.Visible = false;
                btnCancelIntrenal.Visible = true;
            }
        }

    }