// update wacthed job details
 public bool UpdateWatchedJob(WatchedJob wJob)
 {
     try
     {
         DALRecruiterWebsiteManager DALMngr = new DALRecruiterWebsiteManager();
         bool result = DALMngr.UpdateWatchedJobDetails(wJob);
         return result;
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        // insert watched jopb details
        public bool UpdateWatchedJobDetails(WatchedJob watchedJob)
        {
            bool result = false;
            try
            {
                using (SqlConnection Cxn = new SqlConnection(CxnString))
                {
                    using (SqlCommand Cmd = new SqlCommand("spUpdateWatchedJobs", Cxn))
                    {
                        Cmd.CommandType = CommandType.StoredProcedure;

                        SqlParameter UpdateJSIDParam = new SqlParameter("@JSID", SqlDbType.Int, 4);
                        SqlParameter UpdateFinanceParam = new SqlParameter("@Finance", SqlDbType.Bit);
                        SqlParameter UpdateComputingParam = new SqlParameter("@Computing", SqlDbType.Bit);
                        SqlParameter UpdateRetailParam = new SqlParameter("@Retail", SqlDbType.Bit);
                        SqlParameter UpdateSalesParam = new SqlParameter("@Sales", SqlDbType.Bit);
                        SqlParameter UpdateEngineeringParam = new SqlParameter("@Engineering", SqlDbType.Bit);
                        SqlParameter UpdateLegalParam = new SqlParameter("@Legal", SqlDbType.Bit);
                        SqlParameter UpdateTourismParam = new SqlParameter("@Tourism", SqlDbType.Bit);
                        SqlParameter UpdatePublishingParam = new SqlParameter("@Publishing", SqlDbType.Bit);
                        SqlParameter UpdateTelecomsParam = new SqlParameter("@Telecoms", SqlDbType.Decimal);
                        SqlParameter UpdateManufacturingParam = new SqlParameter("@Manufacturing", SqlDbType.Bit);

                        UpdateJSIDParam.Value = watchedJob.JobseekerID;
                        UpdateFinanceParam.Value = watchedJob.Finance;
                        UpdateComputingParam.Value = watchedJob.Computing;
                        UpdateRetailParam.Value = watchedJob.Retail;
                        UpdateSalesParam.Value = watchedJob.Sales;
                        UpdateEngineeringParam.Value = watchedJob.Engineering;
                        UpdateLegalParam.Value = watchedJob.Legal;
                        UpdateTourismParam.Value = watchedJob.Tourism;
                        UpdatePublishingParam.Value = watchedJob.Publishing;
                        UpdateTelecomsParam.Value = watchedJob.Telecoms;
                        UpdateManufacturingParam.Value = watchedJob.Manufacturing;

                        Cmd.Parameters.Add(UpdateJSIDParam);
                        Cmd.Parameters.Add(UpdateFinanceParam);
                        Cmd.Parameters.Add(UpdateComputingParam);
                        Cmd.Parameters.Add(UpdateRetailParam);
                        Cmd.Parameters.Add(UpdateSalesParam);
                        Cmd.Parameters.Add(UpdateEngineeringParam);
                        Cmd.Parameters.Add(UpdateLegalParam);
                        Cmd.Parameters.Add(UpdateTourismParam);
                        Cmd.Parameters.Add(UpdatePublishingParam);
                        Cmd.Parameters.Add(UpdateTelecomsParam);
                        Cmd.Parameters.Add(UpdateManufacturingParam);


                        Cxn.Open();
                        int i = Cmd.ExecuteNonQuery();
                        if (i > 0)
                        {

                            result = true;
                        }
                        else
                        {
                            result = false;
                        }
                        Cxn.Close();


                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
            return result;
        }
        private void GetSelectedJobs()
        {
            int wjID = (int)Session["JobseekerID"];

            bool finance = false;
            bool computing = false;
            bool retail = false;
            bool sales = false;
            bool engineering = false;
            bool legal = false;
            bool tourism = false;
            bool publishing = false;
            bool telecoms = false;
            bool manufacturing = false;

            if(listJobs.Items[0].Selected)
            {
                finance = true;
            }
            if (listJobs.Items[1].Selected)
            {
                computing = true;
            }
            if (listJobs.Items[2].Selected)
            {
                retail = true;
            }
            if (listJobs.Items[3].Selected)
            {
                sales = true;
            }
            if (listJobs.Items[4].Selected)
            {
                engineering = true;
            }
            if (listJobs.Items[5].Selected)
            {
                legal = true;
            }
            if (listJobs.Items[6].Selected)
            {
                tourism = true;
            }
            if (listJobs.Items[7].Selected)
            {
                publishing = true;
            }
            if (listJobs.Items[8].Selected)
            {
                telecoms = true;
            }
            if (listJobs.Items[9].Selected)
            {
                manufacturing = true;
            }
            try
            {
                WatchedJob watchedJob = new WatchedJob(wjID, finance, computing, retail, sales, engineering, legal, tourism, publishing, telecoms, manufacturing);
                BLLRecruiterWebsiteManager BLLMngr = new BLLRecruiterWebsiteManager();
                bool result = BLLMngr.InsertWatchedJob(watchedJob);
                if (result == true)
                {
                    Response.Redirect("~/JobseekerProfile.aspx");
                }
            }
            catch(Exception ex)
            {
                throw;
            }
        }
        // get list of watched jobs
        public List<WatchedJob> GetListOfWatchedJobsFromDB()
        {
            List<WatchedJob> WSList = new List<WatchedJob>();

            try
            {
                using (SqlConnection Cxn = new SqlConnection(CxnString))
                {
                    using (SqlCommand Cmd = new SqlCommand("spGetWatchedJobs", Cxn))
                    {
                        Cmd.CommandType = CommandType.StoredProcedure;


                        Cxn.Open();
                        dr = Cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            int WJID = Convert.ToInt32(dr.GetValue(Convert.ToInt32(WJ_GetWatchedJob.SP_WacthedJobID)));
                            int JSID = Convert.ToInt32(dr.GetValue(Convert.ToInt32(WJ_GetWatchedJob.SP_JSID)));
                            bool finance = dr.GetBoolean(Convert.ToInt32(WJ_GetWatchedJob.SP_Finance));
                            bool computing = dr.GetBoolean(Convert.ToInt32(WJ_GetWatchedJob.SP_Computing));
                            bool retail = dr.GetBoolean(Convert.ToInt32(WJ_GetWatchedJob.SP_Retail));
                            bool sales = dr.GetBoolean(Convert.ToInt32(WJ_GetWatchedJob.SP_Sales));
                            bool engineering = dr.GetBoolean(Convert.ToInt32(WJ_GetWatchedJob.SP_Engineering));
                            bool legal = dr.GetBoolean(Convert.ToInt32(WJ_GetWatchedJob.SP_Legal));
                            bool tourism = dr.GetBoolean(Convert.ToInt32(WJ_GetWatchedJob.SP_Tourism));
                            bool publishing = dr.GetBoolean(Convert.ToInt32(WJ_GetWatchedJob.SP_Publishing));
                            bool telecoms = dr.GetBoolean(Convert.ToInt32(WJ_GetWatchedJob.SP_Telecoms));
                            bool manufacturing = dr.GetBoolean(Convert.ToInt32(WJ_GetWatchedJob.SP_Manufacturing));

                            /*Finance,
                            Computing,
                            Retail,
                            Sales,
                            Engineering,
                            Legal,
                            Tourism,
                            Publishing,
                            Telecoms,
                            Manufacturing*/

                            WatchedJob wJob = new WatchedJob(JSID, finance, computing, retail, sales, engineering, legal, tourism, publishing, telecoms, manufacturing);
                            wJob.WatchedJobID = WJID;
                            WSList.Add(wJob);
                        }
                        dr.Close();
                        Cxn.Close();
                    }
                }
                return WSList;
            }
            catch (Exception ex)
            {
                throw;
            }

        }