LotteryRepository

Handles the data in the Firestore database for the Lottery class.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Cached lotteries synchronized with Firestore.

Functions

Link copied to clipboard
suspend fun addLottery(lottery: Lottery)

Adds a new lottery to the Firestore database.

Link copied to clipboard
suspend fun addWaitlistToLottery(lottery: Lottery, waitlistEntry: WaitlistEntry): Boolean

Adds a waitlist entry to a specified lottery if there is enough space left.

Link copied to clipboard
suspend fun deleteLottery(lottery: Lottery)

Deletes a lottery from the Firestore database.

Link copied to clipboard

Gets all Lottery that is created by a specific campsite.

Link copied to clipboard
suspend fun getLottery(lotteryId: String): Lottery?

Gets a Lottery object from the database given its lotteryId.

Link copied to clipboard
fun joinLottery(lotteryId: String, entrantId: String, numberOfGuests: Int, onResult: (Boolean, String) -> Unit)

Registers an entrant for a lottery and adds their entry to the Firestore database.

Link copied to clipboard
suspend fun removeWaitlistFromLottery(lottery: Lottery, waitlistEntry: WaitlistEntry)

Removes a waitlist entry from a specified lottery. If the waitlist entry is not in the lottery, the function does nothing.

Link copied to clipboard
suspend fun updateLottery(updatedLottery: Lottery)

Saves a lottery to Firestore, creating it if absent.