Пример #1
0
 public Model.Employee Authenticate(string emailId, string password)
 {
     Model.Employee employee=new Model.Employee();
     SqlConnection con = new SqlConnection("Data Source=TRAINING12;Initial Catalog=Employee;User ID=sa;Password=test123!@#");
     con.Open();
     SqlCommand cmd = new SqlCommand("Authenticate", con);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.Add(new SqlParameter("@emailId",emailId));
     cmd.Parameters.Add(new SqlParameter("@password",password));
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
        EmployeeStorage storageObject= new EmployeeStorage();
        employee = storageObject.Get(dr[0].ToString(), "1");
        return employee;
     }
     con.Close();
     return null;
 }
Пример #2
0
        public bool UpdatePassword(string oldPassword,string newPassword,string emailId)
        {
            EmployeeStorage storageObject = new EmployeeStorage();
            var employee =storageObject.Authenticate(emailId,oldPassword);
            if (employee == null)
            {
                return false;
            }

            SqlConnection con = new SqlConnection("Data Source=TRAINING12;Initial Catalog=Employee;User ID=sa;Password=test123!@#");
            con.Open();
            SqlCommand cmd = new SqlCommand("UpdatePassword", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@Password", newPassword));
            cmd.Parameters.Add(new SqlParameter("@Id", employee.Id));

            cmd.ExecuteNonQuery();
            con.Close();
            return true;
        }