Exemplo n.º 1
0
        public static void SubscribeToTeacher(string teacherEmail, string userId)
        {
            //get the teacher's userId from the email address the user entered
            DataHandler handler = new DataHandler();
            string select = "SELECT UserId FROM aspnet_Membership WHERE LoweredEmail = '" + teacherEmail.ToLower() + "'";
            string teacherId = handler.ExecuteScalar(select);

            //add the teacher to the student by the teacher's userId
            string insert = "INSERT INTO user_UserHasTeachers (TeacherId, UserId) VALUES ('" + teacherId + "', '" + userId + "')";
            handler.ExecuteNonQuery(insert);
        }
        public int GetProspectiveStudentCount(string UserId)
        {
            handler = new DataHandler();
            //this find students that added a teacher but do not exist in their group
            //critical: needs to include a comparison to the teacher's groups
            //right now, a student could be in someone else's group and this would exlude from from this teacher's query
            string select =
                "SELECT COUNT(aspnet_Users.UserName) " +
                "FROM user_UserHasTeachers, aspnet_Users " +
                "WHERE TeacherId = '" + UserId + "' " +
                "AND aspnet_Users.UserId = user_UserHasTeachers.UserId " +
                "AND aspnet_Users.UserId NOT IN " +
                    "(SELECT UserId FROM user_UsersInGroups)";

            int count;
            int.TryParse(handler.ExecuteScalar(select), out count);
            return count;
        }