public List<DataObjectSessionAttendee> GetAll()
 {
     SqlConnection conn = new SqlConnection(connectionString);
     conn.Open();
     List<DataObjectSessionAttendee> DataTemplateODSList = new List<DataObjectSessionAttendee>();
     SqlDataReader reader = null;
     string sqlSelectString = "SELECT sessions_id,attendees_username,interestlevel,id FROM SessionAttendee";
     SqlCommand cmd = new SqlCommand(sqlSelectString, conn);
     reader = cmd.ExecuteReader();
     try
     {
         while (reader.Read())
         {
             int sessions_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
             Guid attendees_username = reader.IsDBNull(1) ? Guid.NewGuid() : reader.GetGuid(1);
             int interestlevel = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
             int id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
             DataObjectSessionAttendee td = new DataObjectSessionAttendee(sessions_id, attendees_username, interestlevel, id);
             DataTemplateODSList.Add(td);
         }
     }
     finally
     {
         if (reader != null) reader.Close();
     }
     conn.Close();
     return DataTemplateODSList;
 }
        public List<DataObjectSessionAttendee> GetBySessionId(int searchsessions_id)
        {
            List<DataObjectSessionAttendee> DataTemplateODSList = null;
            string cacheName = CodeCampSV.Utils.CacheSessionAttendeeBySessionId + "_" + searchsessions_id.ToString();

            //$$$ PROBLEM, MOVE THIS OUT OF IF STATMENT
            if (HttpContext.Current.Cache[cacheName] == null)
            {

                SqlConnection conn = new SqlConnection(connectionString);
                conn.Open();
                DataTemplateODSList = new List<DataObjectSessionAttendee>();
                SqlDataReader reader = null;
                string sqlSelectString = "SELECT sessions_id,attendees_username,interestlevel,id FROM [dbo].[SessionAttendee]  WHERE sessions_id = @searchsessions_id";
                SqlCommand cmd = new SqlCommand(sqlSelectString, conn);
                cmd.Parameters.Add("@searchsessions_id", SqlDbType.Int, 4).Value = searchsessions_id; ;
                reader = cmd.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        int sessions_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        Guid attendees_username = reader.IsDBNull(1) ? Guid.NewGuid() : reader.GetGuid(1);
                        int interestlevel = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        int id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        DataObjectSessionAttendee td = new DataObjectSessionAttendee(sessions_id, attendees_username, interestlevel, id);
                        DataTemplateODSList.Add(td);
                    }
                }
                finally
                {
                    if (reader != null) reader.Close();
                }
                conn.Close();
                HttpContext.Current.Cache.Insert(cacheName, DataTemplateODSList,
                   null, DateTime.Now.Add(new TimeSpan(0, 0, Utils.RetrieveSecondsForSessionCacheTimeout())), TimeSpan.Zero);
            }
            else
            {
                DataTemplateODSList = (List<DataObjectSessionAttendee>)HttpContext.Current.Cache[cacheName];
            }

            return DataTemplateODSList;
        }
        public List<DataObjectSessionAttendee> GetByUsername(string username)
        {
            List<DataObjectSessionAttendee> DataTemplateODSList = new List<DataObjectSessionAttendee>();
            string cacheName = CodeCampSV.Utils.CacheSessionAttendeeByUsername + "_" + username ;
            if (HttpContext.Current.Cache[cacheName] == null)
            {
                SqlConnection conn = new SqlConnection(connectionString);
                conn.Open();
                DataTemplateODSList = new List<DataObjectSessionAttendee>();
                SqlDataReader reader = null;
                string sqlSelectString =
                @"
                 SELECT sessions_id,
                       attendees_username,
                       interestlevel,
                       id
                 FROM SessionAttendee
                 WHERE attendees_username =
                       (select PKID from Attendees WHERE Username = @Username)
                ";

                SqlCommand cmd = new SqlCommand(sqlSelectString, conn);
                cmd.Parameters.Add("@Username", SqlDbType.VarChar).Value = username;
                reader = cmd.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        int sessions_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        Guid attendees_username = reader.IsDBNull(1) ? Guid.NewGuid() : reader.GetGuid(1);
                        int interestlevel = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        int id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        var td = new DataObjectSessionAttendee(sessions_id, attendees_username, interestlevel, id);
                        DataTemplateODSList.Add(td);

                        //// interested = 2; plan to attend  = 3
                        //if (radioButtonInterestLevel.Equals("All"))
                        //{
                        //    DataTemplateODSList.Add(td);
                        //}
                        //else if (radioButtonInterestLevel.Equals("Interested"))
                        //{
                        //    if (interestlevel == 2)
                        //    {
                        //        DataTemplateODSList.Add(td);
                        //    }
                        //}
                        //else if (radioButtonInterestLevel.Equals("Plan To Attend"))
                        //{
                        //    if (interestlevel == 3)
                        //    {
                        //        DataTemplateODSList.Add(td);
                        //    }
                        //}
                        //else if (radioButtonInterestLevel.Equals("I & P2A"))
                        //{
                        //    if (interestlevel == 3 || interestlevel == 2)
                        //    {
                        //        DataTemplateODSList.Add(td);
                        //    }
                        //}
                    }
                }
                finally
                {
                    if (reader != null) reader.Close();
                }
                conn.Close();

                // DON'T CACHE THIS BECAUSE PERSON MAY BE CHANGING SELECTIONS, PROBABLY SHOULD NOT EVEN HAVE I LOOP
                int cacheTime = Utils.RetrieveSecondsForSessionCacheTimeout();
                cacheTime = 3; // make small just in case site hammered
                HttpContext.Current.Cache.Insert(cacheName, DataTemplateODSList,
                    null, DateTime.Now.Add(new TimeSpan(0, 0,cacheTime)), TimeSpan.Zero);
            }
            else
            {
                DataTemplateODSList = (List<DataObjectSessionAttendee>)HttpContext.Current.Cache[cacheName];
            }
            return DataTemplateODSList;
        }