Exemplo n.º 1
0
        /// <summary>
        /// Patron check-in to a gaming service.
        /// </summary>
        /// <param name="venueId">Target venue ID</param>
        /// <param name="areaId">Target area ID</param>
        /// <param name="checkIn">Check-in information</param>
        public async Task SubmitGamingCheckIn(string venueId, string areaId, GamingCheckInRequest checkIn)
        {
            // Check that the venue exists, the area exists, the area is open, and the area type is gaming.
            // This will throw an error if the venue doesn't exist.
            var venue = await _database.GetVenueById(venueId);

            // Find an area that matches the requested areaId
            var area = venue.GamingAreas.Find(a => a.Id.Equals(areaId));

            // Throw an exception if the area does not exist.
            if (area == null)
            {
                throw new AreaNotFoundException();
            }

            // Throw an exception if the area is not open.
            if (!area.IsOpen)
            {
                throw new AreaIsClosedException();
            }

            // Throw an exception if there is no active service.
            if (area.ActiveService == "NONE")
            {
                throw new ServiceNotFoundException();
            }

            // Create a new GamingPatron document.
            GamingPatronDocument patron = new GamingPatronDocument
            {
                Id           = ObjectId.GenerateNewId().ToString(),
                FirstName    = checkIn.FirstName,
                LastName     = checkIn.LastName,
                PhoneNumber  = checkIn.PhoneNumber,
                CheckInTime  = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
                CheckOutTime = -1,
                IsActive     = true
            };

            // Save the check-in.
            await _database.SaveGamingCheckIn(area.ActiveService, patron);
        }