//GetPairedCinderellas
        //gets up to 15 paired cinderellas
        //Input: a List to hold the paired cinderellas, and information pulled down from the DB
        //Output: the list has been filled with at most 15 paired cinderellas
        //precondition: the DB is in a correct and valid state
        //postcondition: the DB is stil in a correct and valid state, and no suplicates have been added to the list
        public void GetPairedCinderellas(ref List<CinderellaClass> PairedCinderella)
        {
            //sets up the query to get at most 15 paired cinderellas
            string query = sql.CinderellasList(15, 3);
            //sets up the connection and the sqlDataReader
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);

            SqlCommand command = new SqlCommand(query, conn);
            conn.Open();
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                //read from DB into cinderella class
                CinderellaClass cinder = new CinderellaClass(reader.GetString(1), reader.GetString(2), reader.GetInt32(0), reader.GetDateTime(3));
                bool canInsert = true;
                foreach (CinderellaClass cinderella in PairedCinderella)
                {//checks to see if the paired cinderella is already in the list and if not add them to it
                    if (cinderella.getCinderellaID() == cinder.getCinderellaID())
                    {
                        canInsert = false;
                    }
                }
                if (canInsert)
                {
                    PairedCinderella.Add(cinder);
                }
            }
            //clean up
            reader.Close();
            conn.Close();
        }
        //MakeMatch
        //handles a single matchmaking attempt
        //Input: queued cinderellas and godmothers, and empty lists for them, to be added to.
        //Output: Lists are updates with the matches
        //preconditions: the lists that are past are without error, complete in the data that they should contain, and none of them have been matched
        //Postconditions: the cinderellas have been amtched are moved to the matched lists
        public void MakeMatch(ref List<CinderellaClass> CinderellaQueue, ref List<FairyGodmother> GodMotherQueue, ref List<CinderellaClass> MatchedCinderellas, ref List<FairyGodmother> MatchedGodMother)
        {
                //Create two objects to hold the cinderellas and godmothers at the head of the queue
                CinderellaClass Cinderella = new CinderellaClass();
                FairyGodmother GodMother = new FairyGodmother();
                //get the cinderella at the head of the queue
                Cinderella = CinderellaQueue[0];
                //do the same for the godmother
                if (GodMotherQueue.Count > 0)
                {
                    GodMother = GodMotherQueue[0];
                }
                else
                {
                    GodMother = null;
                }
                //handle the best case, not special needs, no requested godmother
                if ((Cinderella.SpecialNeeds == false) && (Cinderella.RequestedGodMother == 0))
                {
                    if (GodMother != null)
                    {//deqeue the cinderella and god mother and add the match to thier appropiate lists
                        MatchedCinderellas.Add(Cinderella);
                        CinderellaQueue.RemoveAt(0);
                        MatchedGodMother.Add(GodMother);
                        GodMotherQueue.RemoveAt(0);
                    }
                }
                //special needs, no requested godmother
                if ((Cinderella.SpecialNeeds == true) && (Cinderella.RequestedGodMother == 0))
                {
                    int id = FindSpecialGodMother(ref GodMotherQueue);
                    if ((GodMother != null) && (0 > -1))//there is an availible godmother that can handle special needs
                    {
                        MatchedCinderellas.Add(Cinderella);
                        CinderellaQueue.RemoveAt(0);//deqeue cinderella
                        MatchedGodMother.Add(GodMotherQueue[id]);
                        GodMotherQueue.RemoveAt(id);//deqeue GodMother
                    }
                }
                //requested godmother
                if (Cinderella.RequestedGodMother != 0)
                {
                    if (GodMother != null)
                    {
                        int id = FindGodMotherByID(Cinderella.RequestedGodMother, ref GodMotherQueue);
                        if (id > -1)
                        {//the Requested GodMother is availible
                            MatchedCinderellas.Add(Cinderella);
                            CinderellaQueue.RemoveAt(0);//deqeue cinderella
                            MatchedGodMother.Add(GodMotherQueue[id]);
                            GodMotherQueue.RemoveAt(id);//deqeue GodMother
                        }
                        else
                        {//the GodMother is not availible at the moment

                        }
                    }
            }
        }
        //GetCinderellas
        //Fills a list with the cindererllas from the DB
        //Input: a list to hold the cinderellas, and information pulled down from the DB
        //Output: the list of cinderellas has been filled with at most 15 cinderellas
        //precondition: the DB is in a correct and valid state
        //postcondition: the DB is still in a correct and valid state,a nd no duplicate cinderellas ahve been added to the list
        public void GetCinderellas(ref List<CinderellaClass> Cinderella)
        {
            //sets up the query to get 15 cinderellas that have the correct status
            string query = sql.CinderellasList(15,2);
            //sets up the sql connection and sqlDataReader
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);

            SqlCommand command = new SqlCommand(query, conn);
            conn.Open();
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                //read from DB into cinderella class
                CinderellaClass cinder = new CinderellaClass(reader.GetString(1), reader.GetString(2), reader.GetInt32(0), Convert.ToDateTime(reader.GetDateTime(3)));
                //check to see if the cinderella is already in the list
                bool cinderellaExists = false;
                foreach (CinderellaClass cinderellaToAdd in Cinderella)
                {
                    if (cinderellaToAdd.getCinderellaID() == cinder.getCinderellaID())
                    {
                        cinderellaExists = true;
                    }
                }
                //if the cinderella doesnt exist add them
                if (cinderellaExists == false)
                {
                    Cinderella.Add(cinder);
                }
            }
            //clean up
            reader.Close();
            conn.Close();
        }
        //GetCinderellas
        //Fills a list with the cindererllas from the database.
        //Input: the list of cindererllas that have been through matchmaking before, a list to fill with cindererllas, and the amount to get
        //Output: updated list of cindererllas pulled down from the db
        //precondition: all inputs are valid, and the database is functioning correctly and the data in it has no errors
        //postcondition: the queue is generated correctly
        void GetCinderellas(ref List<CinderellaClass> Cinderella, int count, ref List<int> oldCinderellas)
        {
            //sets up the query to get 15 cinderellas that have the correct status
            string query = sql.CinderellasList(15, 2);
            //sets up the sql connection and sqlDataReader
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);

            SqlCommand command = new SqlCommand(query, conn);
            conn.Open();
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                //read from DB into cinderella class
                CinderellaClass cinder = new CinderellaClass(reader.GetString(1), reader.GetString(2), reader.GetInt32(0), Convert.ToDateTime(reader.GetDateTime(3)));
                //check to see if the cinderella is already in the list
                bool cinderellaExists = false;
                bool priority = false;
                foreach (CinderellaClass cinderellaToAdd in Cinderella)
                {
                    if (cinderellaToAdd.getCinderellaID() == cinder.getCinderellaID())
                    {
                        cinderellaExists = true;
                    }
                }
                if (cinderellaExists == false)
                    //cinderella doesnt exist, add to list
                {
                    if (count < 15)
                    {
                        //check to see if the cinderella has been through before
                        foreach (int id in oldCinderellas)
                        {
                            if (cinder.getCinderellaID() == id)
                            {
                                priority = true;
                            }
                        }
                        if (priority)
                            //cinderella has been through before, she gets added to the front of the queue
                        {
                            Cinderella.Insert(0, cinder);
                        }
                        else
                            //cinderella has not been through before, added normally
                        {
                            Cinderella.Add(cinder);
                        }
                    }
                    count += 1;
                }
            }
            //clean up
            reader.Close();
            conn.Close();
        }