コード例 #1
0
        public static List <Customer> ListOfCustomers()
        {
            DatabaseInterface db = new DatabaseInterface("BANGAZONCLI_DB");

            db.Query("select id, firstname, lastname from customer",
                     (SqliteDataReader reader) => {
                customers.Clear();
                while (reader.Read())
                {
                    customers.Add(new Customer()
                    {
                        id        = reader.GetInt32(0),
                        FirstName = reader[1].ToString(),
                        LastName  = reader[2].ToString()
                    });
                }
            });
            return(customers);
        }
コード例 #2
0
        //This method was authored by Jordan Dhaenens
        //This method serves to retrieve all customers, eventually

        /*This Method ammended by Krissy Caron:
         * Includes the query to return all customers currently in the database */
        public List <Customer> GetCustomers()
        {
            _db.Query("select CustomerId, FirstName, LastName, Email, Phone, DateAccountCreated from Customer",
                      (SqliteDataReader reader) => {
                _customers.Clear();
                while (reader.Read())
                {
                    _customers.Add(new Customer()
                    {
                        CustomerId         = reader.GetInt32(0),
                        FirstName          = reader[1].ToString(),
                        LastName           = reader[2].ToString(),
                        Email              = reader[3].ToString(),
                        Phone              = reader[4].ToString(),
                        DateAccountCreated = reader.GetDateTime(5)
                    });
                }
            });
            return(_customers);
        }
コード例 #3
0
        public static void Initialize(DatabaseInterface dab)
        {
            bool customersExist = false;

            dab.Query($"select id from customer",
                      (SqliteDataReader reader) => {
                while (reader.Read())
                {
                    customersExist = true;
                }
                if (customersExist == false)
                {
                    dab.BulkInsert($@"
                        insert into customer values(null, 'Bobby', 'Schmurda', 'Rykers Island', 'Brooklyn', 'NY', '12345', '555-555-5555');
                        insert into customer values(null, 'Lil', 'Pump', '2 Main St.', 'Miami', 'FL', '23456', '555-555-5551');
                        insert into customer values(null, 'Smoke', 'Purpp', '3 Main St.', 'Miami', 'FL', '34567', '555-555-5552');

                        insert into paymentType values(null, 'Cash', 1, 12);
                        insert into paymentType values(null, 'Visa', 2, 13);
                        insert into paymentType values(null, 'MasterCard', 3, 13);

                        insert into [order] values (null, 1, 1);
                        insert into [order] values(null, 2, 2);
                        insert into [order] values(null, 3, 3);

                        insert into product values (null, 'Codine Cough Syrup', 3, 12.99, 1, 'Goes great with Sprite!');
                        insert into product values (null, 'SoundCloud Subscription', 2, 9.99, 2, 'Where all the good hip hop is at');
                        insert into product values (null, 'Soccer Ball', 1, 10.99, 3, 'Kick goals with it!');

                        insert into productOrder values (null, 1, 2);
                        insert into productOrder values (null, 2, 1);
                        insert into productOrder values (null, 3, 3);
                    ");
                }
            });
        }