getFairyID() публичный Метод

public getFairyID ( ) : int
Результат int
        //GetGodMothers
        //fills a list with GodMothers from the DB
        //Input: a list to hold the GodMothers, and information pulled down from the DB
        //Output: the list of GodMothers has been filled with at most 15 GodMothers
        //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 GodMothers have been added to the list
        public void GetGodMothers(ref List<FairyGodmother> godMother)
        {
            //sets up the query to get 15 pending godmothers
            string query = sql.PersonalShoppersList(15, 4);
            //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 godmother class
                FairyGodmother NewFairyGodmother = new FairyGodmother(reader.GetInt32(0), reader.GetString(1), reader.GetString(2));
                bool canInsert = true;
                foreach (FairyGodmother shopper in godMother)
                {
                    //check to see if the godmother is already in the list and if not add them to it
                    if (shopper.getFairyID() == NewFairyGodmother.getFairyID())
                    {
                        canInsert = false;
                    }
                }
                if (canInsert)
                {
                    godMother.Add(NewFairyGodmother);
                }
            }
            //clean up
            reader.Close();
            conn.Close();
        }
        //GetPairedGodMother
        //gets the godmothers who are paired to each of the cinderellas in the pairedcinderella list
        //Input: the list of paired cinderellas, a list to hold the godmothers, and information pulled down from the db
        //Output: the godmother list filled with the godmothers paired to the cinderellas
        //precondition: the pairedcinderella and the DB are in a correct and valid state
        //postcondition: the godmother list has correctly filled, and the DB is still in a correct and valid state
        public void GetPairedGodMother(ref List<FairyGodmother> PairedGodMother, ref List<CinderellaClass> PairedCinderella)
        {
            //loops through to get the godmother that is matched to each cinderella
            foreach (CinderellaClass cinderella in PairedCinderella)
            {
            //sets up the query to get the godmother paired to the cinderella
            string query = sql.PairedPersonalShoppers(cinderella.getCinderellaID());
            //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 godmother class
                FairyGodmother NewFairyGodmother = new FairyGodmother(reader.GetInt32(0), reader.GetString(1), reader.GetString(2));
                bool canInsert = true;
                foreach (FairyGodmother shopper in PairedGodMother)
                {//checks to see if the godmotehr is already in the list and if not add them to it
                    if (shopper.getFairyID() == NewFairyGodmother.getFairyID())
                    {
                        canInsert = false;
                    }
                }
                if (canInsert)
                {
                    PairedGodMother.Add(NewFairyGodmother);
                }
            }
            //clean up
            reader.Close();
            conn.Close();
            }
        }
Пример #3
0
        //GetGodMothers
        //Fills a list with the GodMothers from the DB
        //Input: the list of GodMothers that have been through matchmaking before, a list to fill with GodMothers, and the amount to get
        //Output: updated list of GodMothers 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 GetGodMothers(ref List<FairyGodmother> godMother, int count, ref List<int> oldGodMothers)
        {
            //sets up the query to get 15 pending godmothers
            string query = sql.PersonalShoppersList(15, 4);
            //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 godmother class
                FairyGodmother NewFairyGodmother = new FairyGodmother(reader.GetInt32(0), reader.GetString(1), reader.GetString(2));
                bool godmotherexists = false;
                bool priority = false;
                //check to see if the god motehr is already in the list
                foreach (FairyGodmother shopper in godMother)
                {
                    if (NewFairyGodmother.getFairyID() == shopper.getFairyID())
                    {
                        godmotherexists = true;
                    }
                }
                //godmother doesnt exist, time to add it to the list
                if (godmotherexists == false)
                {
                    //check to see if the god motehr has been through before
                    foreach (int id in oldGodMothers)
                    {
                        if (NewFairyGodmother.getFairyID() == id)
                        {
                            priority = true;
                        }
                    }
                    if (priority)
                        //god mother has been through before add to the front of the queue
                    {
                        godMother.Insert(0, NewFairyGodmother);
                    }
                    else
                        //add normally
                    {
                        godMother.Add(NewFairyGodmother);
                    }
                }
            }
            //clean up
            reader.Close();
            conn.Close();
        }