Exemple #1
0
        /// <summary>
        /// Close a DJ's session. The DJ must have a session running for this to work.
        /// </summary>
        /// <param name="DJKey">The DJKey assigned to the DJ.</param>
        /// <returns>The outcome of the operation.b</returns>
        public Response DJStopSession(long DJKey)
        {
            int DJID = -1;
            using (DatabaseConnectivity db = new DatabaseConnectivity())
            {
                // Try to establish a database connection
                Response r = db.OpenConnection();
                if (r.error)
                    return r;

                // Attempt to convert DJKey to DJID
                r = DJKeyToID(DJKey, out DJID, db);
                if (r.error)
                    return r;

                // Make sure the DJ has a session running.
                r = DJValidateStatus(DJID, "2", db);
                if (r.error)
                    return r;

                // Set the status of the DJ to logged in.
                r = db.DJSetStatus(DJID, 1);
                if (r.error)
                    return r;

                Common.PushMessageToUsersOfDJ(DJID, "exit", db);

                // Delete the song request field.
                r = db.DJDeleteSongRequests(DJID);
                if (r.error)
                    return r;

                r = db.DJRemoveAllTempUsers(DJID);
                if (r.error)
                    return r;

                r = db.DJRemoveUsersFromVenue(DJID);
                if (r.error)
                    return r;

                return r;
            }
        }
Exemple #2
0
        /// <summary>
        /// Attempt to sign out the DJ. 
        /// </summary>
        /// <param name="DJKey">The DJKey of the DJ.</param>
        /// <returns>The outcome of the operation.</returns>
        public Response DJSignOut(long DJKey)
        {
            int DJID;
            using (DatabaseConnectivity db = new DatabaseConnectivity())
            {
                // Try to establish a database connection
                Response r = db.OpenConnection();
                if (r.error)
                    return r;

                // Convert the DJKey to a DJID
                r = DJKeyToID(DJKey, out DJID, db);
                if (r.error)
                    return r;

                // Make sure the DJ is not logged out.
                r = DJValidateStatus(DJID, "!0", db);
                if (r.error)
                    return r;

                // A sign out seems to be valid.
                r = db.DJSetStatus(DJID, 0);
                if (r.error)
                    return r;

                Common.PushMessageToUsersOfDJ(DJID, "exit", db);

                // Remove the key from the DB.
                r = db.DJSetKey(DJID, null);
                if (r.error)
                    return r;

                // Close out the song requests for this DJ.
                r = db.DJDeleteSongRequests(DJID);
                if (r.error)
                    return r;

                r = db.DJRemoveAllTempUsers(DJID);
                if (r.error)
                    return r;

                r = db.DJRemoveUsersFromVenue(DJID);
                if (r.error)
                    return r;

                return r;
            }
        }