Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Common obj = new Common();
                if (Session["ClassificationList"] == null)
                {
                    Session.Add("ClassificationList", obj.JobClassificationList());
                }

                if (Session["LocationList"] == null)
                {
                    Session.Add("LocationList", obj.LocationList());
                }

                if (Session["WorkTypeList"] == null)
                {
                    Session.Add("WorkTypeList", obj.WorkTypeList());
                }

                if (Session["FrequencyList"] == null)
                {
                    Session.Add("FrequencyList", obj.AlertFrequnecyList());
                }

                if (Session["title"] == null)
                {
                    Session.Add("title", obj.TitleList());
                }

                if (Session["gender"] == null)
                {
                    Session.Add("gender", obj.GenderList());
                }

                if (Session["marital"] == null)
                {
                    Session.Add("marital", obj.MaritalList());
                }

                if (Session["phonetype"] == null)
                {
                    Session.Add("phonetype", obj.PhoneTypeList());
                }

                if (Session["currency"] == null)
                {
                    Session.Add("currency", obj.CurrencyList());
                }

                if (Session["frequency"] == null)
                {
                    Session.Add("frequency", obj.FrequencyList());
                }

                if (Session["emailtype"] == null)
                {
                    Session.Add("emailtype", obj.EmailTypeList());
                }

                ListItemCollection y = new ListItemCollection();
                y.Add("");
                ListItemCollection y1 = new ListItemCollection();
                y1.Add("");
                y1.Add("Present");
                for (int i = DateTime.Today.Year; i > (DateTime.Today.Year - 100); i--)
                {
                    y.Add(new ListItem(i.ToString()));
                    y1.Add(new ListItem(i.ToString()));
                }
                Session.Add("year", y);
                Session.Add("Toyear", y1);

                ListItemCollection m = new ListItemCollection();
                m.Add("");
                foreach (string month in months)
                {
                    m.Add(new ListItem(month));
                }
                Session.Add("month", m);

                ListItemCollection d = new ListItemCollection();
                d.Add("");
                for (int i = 1; i <= 31; i++)
                {
                    d.Add(new ListItem(i.ToString()));
                }
                Session.Add("day", d);

                if (Session["OccupationList"] == null)
                {
                    DataTable dt = obj.OccupationList();
                    //DataRow dr = dt.NewRow();
                    //dr[0] = "";
                    //dr[1] = "-- Any --";

                    //dt.Rows.InsertAt(dr, 0);
                    Session.Add("OccupationList", dt);
                }

                if (Session["JobIndustryList"] == null)
                {
                    DataTable dt = obj.JobIndustryList();
                    DataRow dr = dt.NewRow();
                    dr[0] = 0;
                    dr[1] = "-- Any --";
                    dt.Rows.InsertAt(dr, 0);
                    Session.Add("JobIndustryList", dt);
                }

                if (Session["JobIndustryResumeList"] == null)
                {
                    DataTable dt = ((DataTable)Session["JobIndustryList"]).Copy();
                    dt.Rows.RemoveAt(0);
                    DataRow dr = dt.NewRow();
                    dr[0] = "";
                    dr[1] = "- Please Select -";
                    dr[2] = -1;
                    dt.Rows.InsertAt(dr, 0);
                    dr = dt.NewRow();
                    dr[0] = "Other";
                    dr[1] = "Other";
                    dr[2] = 0;
                    dt.Rows.InsertAt(dr, 1);
                    Session.Add("JobIndustryResumeList", dt);
                }

                if (Session["JobIndustySub"] == null)
                {
                    DataTable dt = obj.JobIndustrySubList();
                    DataRow dr = dt.NewRow();
                    dr[0] = 0;
                    dr[1] = "-- Any --";
                    dr[2] = "";
                    dt.Rows.InsertAt(dr, 0);
                    Session.Add("JobIndustySub", dt);
                }

                if (Session["SearchLocationList"] == null)
                {
                    DataTable dt = obj.LocationList();
                    DataRow dr = dt.NewRow();
                    dr[0] = "";
                    dr[1] = "-- Any --";
                    dr[2] = 0;
                    dt.Rows.InsertAt(dr, 0);
                    Session.Add("SearchLocationList", dt);
                }

                if (Session["SearchWorkTypeList"] == null)
                {
                    DataTable dt = obj.WorkTypeList();
                    DataRow dr = dt.NewRow();
                    dr[0] = 0;
                    dr[1] = "-- Any --";

                    dt.Rows.InsertAt(dr, 0);
                    Session.Add("SearchWorkTypeList", dt);
                }
            }
        }
        public ActionResult JobAlertEdit(int alertId, string CID)
        {
            JobAlertModel model = new JobAlertModel();
            JobAlert alert = new JobAlert();
            if (string.IsNullOrEmpty(CID))
            {
                DataTable dt = new DataTable();
                dt = alert.getJobAlert(alertId);
                if (dt.Rows.Count == 0)
                    return View("JobAlertNotExist");
                else
                {
                    if (string.IsNullOrEmpty(dt.Rows[0]["candidateguid"].ToString()))
                    {
                        CID = alert.updateCandidateGUID(Convert.ToInt32(dt.Rows[0]["candidateid"].ToString()));
                        string body = System.IO.File.ReadAllText(Server.MapPath("~/Template") + "/alertupgradesecurity.htm");
                        string address = ConfigurationManager.AppSettings.Get("emailAddress");
                        string displayName = ConfigurationManager.AppSettings.Get("emailName");
                        MailMessage message = new MailMessage
                        {
                            From = new MailAddress(address, displayName),
                            Subject = "Please use the new link to manage your subscription",
                            Body = string.Format(body, dt.Rows[0]["first"].ToString(), "<a href='" + ConfigurationManager.AppSettings["baseURL"].ToString() + "Jobs/JobAlertEdit.shtml" + "?alertId=" + alertId + "&CID=" + CID + "' > click here</a>", "<img src='" + ConfigurationManager.AppSettings["logoURL"].ToString() + "' />"),
                            IsBodyHtml = true
                        };
                        message.To.Add(dt.Rows[0]["email"].ToString());
                        SmtpClient sc = new SmtpClient();
                        sc.Host = ConfigurationManager.AppSettings["smtpHost"].ToString();
                        string smtpUser = ConfigurationManager.AppSettings["smtpUserName"].ToString();
                        string smtpPwd = ConfigurationManager.AppSettings["smtpPassword"].ToString();
                        sc.Credentials = new System.Net.NetworkCredential(smtpUser, smtpPwd);
                        sc.Send(message);

                        return View("JobAlertSecurityUpgrade");
                    }
                    else
                        return View("JobAlertNotExist");
                }
            }

            DataSet ds = alert.getJobAlert(alertId, CID);
            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    model.JobAlertId = Convert.ToInt32(ds.Tables[0].Rows[0]["job_alertId"].ToString());
                    model.CandidateId = Convert.ToInt32(ds.Tables[0].Rows[0]["candidateId"].ToString());
                    model.CandidateGUID = CID;
                    model.Name = ds.Tables[0].Rows[0]["first"].ToString();
                    model.SurName = ds.Tables[0].Rows[0]["last"].ToString();
                    model.Email = ds.Tables[0].Rows[0]["email"].ToString();
                    model.PhoneCode = ds.Tables[0].Rows[0]["phonecode"].ToString();
                    model.ContactNumber = ds.Tables[0].Rows[0]["phonenumber"].ToString();
                    model.MailFrequency = Convert.ToInt32(ds.Tables[0].Rows[0]["frequencyId"].ToString());

                    model.IndustrySelect = new List<int>();
                    foreach (DataRow drSector in ds.Tables[3].Rows)
                    {
                        model.IndustrySelect.Add(Convert.ToInt32(drSector["jobindustrysubid"].ToString()));
                    }

                    model.LocationSelect = new List<int>();
                    foreach (DataRow drLocation in ds.Tables[1].Rows)
                    {
                        model.LocationSelect.Add(Convert.ToInt32(drLocation["locationid"].ToString()));
                    }

                    model.WorkTypeSelect = new List<int>();
                    foreach (DataRow drWorktype in ds.Tables[2].Rows)
                    {
                        model.WorkTypeSelect.Add(Convert.ToInt32(drWorktype["job_typeid"].ToString()));
                    }

                    Common obj = new Common();
                    if (Session["ClassificationList"] == null)
                    {
                        Session.Add("ClassificationList", obj.JobClassificationList());
                    }

                    if (Session["LocationList"] == null)
                    {
                        Session.Add("LocationList", obj.LocationList());
                    }

                    if (Session["WorkTypeList"] == null)
                    {
                        Session.Add("WorkTypeList", obj.WorkTypeList());
                    }

                    if (Session["FrequencyList"] == null)
                    {
                        Session.Add("FrequencyList", obj.AlertFrequnecyList());
                    }

                    if (Session["JobIndustryList"] == null)
                    {
                        DataTable dt = obj.JobIndustryList();
                        DataRow dr = dt.NewRow();
                        dr[0] = "";
                        dr[1] = "-- Any --";
                        dr[2] = 0;
                        dt.Rows.InsertAt(dr, 0);
                        Session.Add("JobIndustryList", dt);
                    }

                    if (Session["JobIndustryResumeList"] == null)
                    {
                        DataTable dt = ((DataTable)Session["JobIndustryList"]).Copy();
                        dt.Rows.RemoveAt(0);
                        DataRow dr = dt.NewRow();
                        dr[0] = "";
                        dr[1] = "- Please Select -";
                        dr[2] = -1;
                        dt.Rows.InsertAt(dr, 0);
                        dr = dt.NewRow();
                        dr[0] = "Other";
                        dr[1] = "Other";
                        dr[2] = 0;
                        dt.Rows.InsertAt(dr, 1);
                        Session.Add("JobIndustryResumeList", dt);
                    }

                    if (Session["JobIndustySub"] == null)
                    {
                        DataTable dt = obj.JobIndustrySubList();
                        DataRow dr = dt.NewRow();
                        dr[0] = 0;
                        dr[1] = "-- Any --";
                        dr[2] = "";
                        dt.Rows.InsertAt(dr, 0);
                        Session.Add("JobIndustySub", dt);
                    }

                    if (Session["SearchLocationList"] == null)
                    {
                        DataTable dt = obj.LocationList();
                        DataRow dr = dt.NewRow();
                        dr[0] = "";
                        dr[1] = "-- Any --";
                        dr[2] = 0;
                        dt.Rows.InsertAt(dr, 0);
                        Session.Add("SearchLocationList", dt);
                    }

                    if (Session["SearchWorkTypeList"] == null)
                    {
                        DataTable dt = obj.WorkTypeList();
                        DataRow dr = dt.NewRow();
                        dr[0] = 0;
                        dr[1] = "-- Any --";
                        dr[2] = "";
                        dt.Rows.InsertAt(dr, 0);
                        Session.Add("SearchWorkTypeList", dt);
                    }
                    return View("JobAlertUpdate", model);
                }
            }
            return View("JobAlertNotExist");
        }