Exemplo n.º 1
0
        private List <CandidateVO> changeToPersonVO(List <Candidate> aps)
        {
            List <CandidateVO> pvos = new List <CandidateVO>();

            foreach (Candidate ap in aps)
            {
                CandidateVO vo = new CandidateVO();
                vo.CandidateId = ap.Id;
                vo.Status      = (int)ap.status;
                var person = context.Person.FirstOrDefault(p => p.PersonNo == ap.PersonNo);
                if (null != person)
                {
                    vo.PersonNo = person.PersonNo;
                    vo.NameEN   = person.NameEN;
                    vo.Mobile   = person.Mobile;
                    vo.Email    = person.Email;
                }
                vo.NameCN = ap.Name;
                pvos.Add(vo);
            }
            return(pvos);
        }
Exemplo n.º 2
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         string username = txtUsername.Text.Trim();
         string password = txtPassword.Text.Trim();
         int    candidateId;
         if (int.TryParse(username, out candidateId) == true)
         {
             candidateVO = candidateBLO.AuthenticateCandidate(candidateId, password);
             if (candidateVO != null)
             {
                 if (chkRemember.Checked)
                 {
                     HttpCookie cookie = new HttpCookie("Candidate");
                     cookie.Values["ID"]     = candidateVO.CandidateId.ToString();
                     cookie.Values["Status"] = candidateVO.Status.ToString();
                     cookie.Expires          = DateTime.Now.AddYears(1);
                     //cookie.Secure = true;
                     Response.Cookies.Add(cookie);
                 }
                 List <string> list = new List <string>();
                 list.Add(candidateVO.CandidateId.ToString());
                 list.Add(candidateVO.Status.ToString());
                 Session.Add("Candidate", list);
                 CheckCandidateLogin();
             }
             else
             {
                 lblError.Text = "Candidate login failed.";
             }
         }
         else
         {
             hrVO = hrBLO.AuthenticateHR(username, password);
             if (hrVO != null)
             {
                 if (chkRemember.Checked)
                 {
                     HttpCookie cookie = new HttpCookie("HR");
                     cookie.Values["Email"] = hrVO.Email.ToString();
                     cookie.Values["Type"]  = hrVO.Type.ToString();
                     cookie.Expires         = DateTime.Now.AddYears(1);
                     //cookie.Secure = true;
                     Response.Cookies.Add(cookie);
                 }
                 List <string> list = new List <string>();
                 list.Add(hrVO.Email.ToString());
                 list.Add(hrVO.Type.ToString());
                 Session.Add("HR", list);
                 CheckHRLogin();
             }
             else
             {
                 lblError.Text = "HR login failed.";
             }
         }
     }
     catch (Exception e1)
     {
         lblError.Text = "Login failed. Please try again";
         Debug.WriteLine("Login Exception Type: " + e1.GetType() +
                         "\nMessage: " + e1.Message +
                         "\nStack Trace: " + e1.StackTrace);
     }
 }