Пример #1
0
        public void DeleteInvitee(Invitee newInvitee)
        {
            MySqlConnection conn = DB.Connection();

            conn.Open();
            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"DELETE FROM events_invitees WHERE events_id = (@eventId) AND invitees_id = (@inviteeId);";
            MySqlParameter inviteeIdParameter = new MySqlParameter();

            inviteeIdParameter.ParameterName = "@inviteeId";
            inviteeIdParameter.Value         = newInvitee.GetId();
            cmd.Parameters.Add(inviteeIdParameter);
            MySqlParameter eventIdParameter = new MySqlParameter();

            eventIdParameter.ParameterName = "@eventId";
            eventIdParameter.Value         = this._id;
            cmd.Parameters.Add(eventIdParameter);
            cmd.ExecuteNonQuery();
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
        }
Пример #2
0
        public void AddInvitee(Invitee newInvitee)
        {
            MySqlConnection conn = DB.Connection();

            conn.Open();
            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"INSERT INTO events_invitees (events_id, invitees_id) VALUES (@eventId, @inviteeId);";
            MySqlParameter inviteeIdParameter = new MySqlParameter();

            inviteeIdParameter.ParameterName = "@inviteeId";
            inviteeIdParameter.Value         = newInvitee.GetId();
            cmd.Parameters.Add(inviteeIdParameter);
            MySqlParameter eventIdParameter = new MySqlParameter();

            eventIdParameter.ParameterName = "@eventId";
            eventIdParameter.Value         = this._id;
            cmd.Parameters.Add(eventIdParameter);
            cmd.ExecuteNonQuery();
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
        }
Пример #3
0
        public List <Invitee> GetInvitees()
        {
            List <Invitee> allEventInvitees = new List <Invitee> {
            };
            MySqlConnection conn            = DB.Connection();

            conn.Open();
            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT *
                            FROM invitees
                           WHERE id IN (SELECT invitees_id FROM events_invitees WHERE events_id = @eventId);";
            MySqlParameter eventId = new MySqlParameter();

            eventId.ParameterName = "@eventId";
            eventId.Value         = this._id;
            cmd.Parameters.Add(eventId);
            var rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                int     inviteeId           = rdr.GetInt32(0);
                string  inviteeName         = rdr.GetString(1);
                string  inviteeEmailAddress = rdr.GetString(2);
                Invitee newInvitee          = new Invitee(inviteeName, inviteeEmailAddress, inviteeId);
                allEventInvitees.Add(newInvitee);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(allEventInvitees);
        }
Пример #4
0
        public static List <Invitee> GetAll()
        {
            List <Invitee> allInvitees = new List <Invitee> {
            };
            MySqlConnection conn       = DB.Connection();

            conn.Open();
            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM invitees;";
            var rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                int     inviteeId           = rdr.GetInt32(0);
                string  inviteeName         = rdr.GetString(1);
                string  inviteeEmailAddress = rdr.GetString(2);
                Invitee newInvitee          = new Invitee(inviteeName, inviteeEmailAddress, inviteeId);
                allInvitees.Add(newInvitee);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(allInvitees);
        }
Пример #5
0
        public static Invitee Find(int id)
        {
            MySqlConnection conn = DB.Connection();

            conn.Open();
            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM invitees WHERE id = (@searchId);";
            MySqlParameter searchId = new MySqlParameter();

            searchId.ParameterName = "@searchId";
            searchId.Value         = id;
            cmd.Parameters.Add(searchId);
            var    rdr                 = cmd.ExecuteReader() as MySqlDataReader;
            int    inviteeId           = 0;
            string inviteeName         = "";
            string inviteeEmailAddress = "";

            while (rdr.Read())
            {
                inviteeId           = rdr.GetInt32(0);
                inviteeName         = rdr.GetString(1);
                inviteeEmailAddress = rdr.GetString(2);
            }
            Invitee newInvitee = new Invitee(inviteeName, inviteeEmailAddress, inviteeId);

            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(newInvitee);
        }
Пример #6
0
 public override bool Equals(System.Object otherInvitee)
 {
     if (!(otherInvitee is Invitee))
     {
         return(false);
     }
     else
     {
         Invitee newInvitee                  = (Invitee)otherInvitee;
         bool    idEquality                  = this.GetId().Equals(newInvitee.GetId());
         bool    inviteeNameEquality         = this.GetInviteeName().Equals(newInvitee.GetInviteeName());
         bool    inviteeEmailAddressEquality = this.GetInviteeEmailAddress().Equals(newInvitee.GetInviteeEmailAddress());
         return(idEquality && inviteeNameEquality && inviteeEmailAddressEquality);
     }
 }