/// <summary> /// Gets the inner error of the specified error from the database /// </summary> /// <param name="conn">Open connection to the database</param> /// <param name="outerError">Outer error</param> /// <returns>Inner error of the specified error, loaded from the database</returns> public static Business.Error GetErrorByOuterError(SqlConnection conn, Business.Error outerError) { try { sql.SqlCommand cmd = new sql.SqlCommand("GetErrorByOuterErrorId", conn); cmd.Parameters.AddWithValue("OuterErrorId", DbType.Int32, outerError.Id); Business.Error[] errors = cmd.ExecuteMappedReader <Business.Error, Int32>(); switch (errors.Length) { case 0: return(null); case 1: return(errors[0]); default: throw new SpecifiedSqlDbObjectNotFoundException(String.Format("{0} rows found in the database", errors.Length)); } } catch (System.Exception e) { throw new SpecifiedSqlDbObjectNotFoundException("Could not load error", e); } }
/// <summary> /// Gets all invites currently in the system /// </summary> /// <param name="conn">Open connection to the database</param> /// <returns>All invites currently in the system</returns> public static Business.Invite[] GetInvites(SqlConnection conn) { try { sql.SqlCommand cmd = new sql.SqlCommand("GetInvites", conn); return(cmd.ExecuteMappedReader <Business.Invite, Int32>()); } catch (System.Exception e) { throw new SpecifiedSqlDbObjectNotFoundException("Could not load invites", e); } }
/// <summary> /// Gets the guests that have not yet been assigned to a table /// </summary> /// <param name="conn">Open connection to the database</param> /// <returns>Guests that have not yet been assigned to a table</returns> public static Business.Guest[] GetUnassignedTableGuests(SqlConnection conn) { try { sql.SqlCommand cmd = new sql.SqlCommand("GetUnassignedTableGuests", conn); return(cmd.ExecuteMappedReader <Business.Guest, Int32>((row => Business.Guest.FromDataRow(row)))); } catch (System.Exception e) { throw new SpecifiedSqlDbObjectNotFoundException("Could not get guests", e); } }
/// <summary> /// Gets the guests that are assigned to the room with the specified unique identifier /// </summary> /// <param name="conn">Open connection to the database</param> /// <param name="roomId">Unique identifier of the room</param> /// <returns>Guests that are assigned to the room with the specified unique identifier</returns> public static Business.Guest[] GetGuestsByRoomId(SqlConnection conn, Int32 roomId) { try { sql.SqlCommand cmd = new sql.SqlCommand("GetGuestsByRoomId", conn); cmd.Parameters.AddWithValue("RoomId", DbType.Int32, roomId); return(cmd.ExecuteMappedReader <Business.Guest, Int32>((row => Business.Guest.FromDataRow(row)))); } catch (System.Exception e) { throw new SpecifiedSqlDbObjectNotFoundException("Could not get guests.", e); } }
/// <summary> /// Loads the messages that belong to the invite with the specified unique identifier from the database /// </summary> /// <param name="conn">Open connection to the database</param> /// <param name="inviteId">Unique identifier of the invite</param> /// <returns>Messages that belong to the invite with the specified unique identifier from the database</returns> internal static Business.Message[] GetMessagesByInviteId(SqlConnection conn, Int32 inviteId) { try { sql.SqlCommand cmd = new sql.SqlCommand("GetMessagesByInviteId", conn); cmd.Parameters.AddWithValue("InviteId", DbType.Int32, inviteId); return(cmd.ExecuteMappedReader <Business.Message, Int32>()); } catch (System.Exception e) { throw new SpecifiedSqlDbObjectNotFoundException("Could not load messages.", e); } }