Пример #1
0
        /// <summary>
        /// Get's invites that are pending that were initiated by the person with the 
        /// corresponding email address.
        /// </summary>
        /// <param name="email">The email address to match.</param>
        /// <returns>A list of invites initiated by the user with the given email.</returns>
        public List<Invitation> GetMyOpenInvites(String email)
        {
            List<Invitation> returnVal = new List<Invitation>();
            MySqlDataReader dr = null;

            String query = "SELECT firstName, lastName, person.personID, email, name, inviteID, invite.timestamp, invitee FROM ";
            query += AppConstants.MYSQL_TABLE_PERSON + " person, " + AppConstants.MYSQL_TABLE_INVITES + " invite, " + AppConstants.MYSQL_TABLE_TEAM + " team ";
            query += "WHERE invite.teamID=team.teamID AND invite.personID=person.personID AND person.email='" + email + "'";

            try {
                connection.Open();
                command.CommandText = query;
                dr = command.ExecuteReader();

                Person invitor;
                Team team;
                Invitation invitation;
                while (dr.Read()) {
                    invitor = new Person(dr.GetString("firstName"), dr.GetString("lastName"));
                    invitor.ID = dr.GetInt64("personID");
                    invitor.email = dr.GetString("email");
                    //invitor.imageURL = dr.GetString("imageURL");
                    //invitor.birthday = dr.GetDateTime("birthday");
                    //invitor.height = dr.GetInt16("height");
                    //invitor.weight = dr.GetInt16("weight");

                    team = new Team();
                    team.name = dr.GetString("name");
                    team.coaches.Add(invitor);

                    invitation = new Invitation(dr.GetInt64("inviteID"), team, invitor);
                    invitation.timestamp = dr.GetDateTime("timestamp");
                    invitation.invitee = dr.GetString("invitee");
                    returnVal.Add(invitation);
                }
            }
            catch {
                returnVal = null;
            }
            finally {
                connection.Close();
            }

            return returnVal;
        }
Пример #2
0
        /// <summary>
        /// Gets the details of a single invitation matching the given invitation ID.
        /// </summary>
        /// <param name="inviteID">The invite ID to search for.</param>
        /// <returns>The details matching the invite ID.</returns>
        public Invitation GetInvite(long inviteID)
        {
            Invitation returnVal = null;
            MySqlDataReader dr = null;

            String query = "SELECT * FROM ";
            query += AppConstants.MYSQL_TABLE_PERSON + " person, " + AppConstants.MYSQL_TABLE_TEAM + " team, " + AppConstants.MYSQL_TABLE_INVITES + " invite ";
            query += "WHERE person.personID=invite.personID AND team.teamID=invite.teamID AND invite.inviteID=" + inviteID;

            try {
                connection.Open();
                command.CommandText = query;
                dr = command.ExecuteReader();

                Person invitor;
                Team team;
                dr.Read();
                invitor = new Person(dr.GetString("firstName"), dr.GetString("lastName"));
                invitor.ID = dr.GetInt64("personID");
                invitor.email = dr.GetString("email");
                //invitor.imageURL = dr.GetString("imageURL");
                //invitor.height = dr.GetInt16("height");
                //invitor.weight = dr.GetInt16("weight");
                //invitor.birthday = dr.GetDateTime("birthday");

                team = new Team();
                team.ID = dr.GetInt64("teamID");
                team.name = dr.GetString("name");
                team.coaches.Add(invitor);

                returnVal = new Invitation(inviteID, team, invitor);
                returnVal.invitee = dr.GetString("invitee");
            }
            catch {
                returnVal = null;
            }
            finally {
                connection.Close();
            }

            return returnVal;
        }