Ejemplo n.º 1
0
        public int CalculateAvailableTickets(Event selectedEvent)
        {
            // returns a count of available tickets
            int tickets = 0;

            int maxTickets = selectedEvent.MaxSeats;

            try
            {
                // check if there are any tickets reserved already
                if (0 != EventAccessor.RetrieveCountEventIDInRoomEvents(selectedEvent.EventID))
                {
                    // if there is, subtract that amount from the maximum amount
                    tickets = maxTickets - EventAccessor.RetrieveCountOfPurchasedTickets(selectedEvent.EventID);
                }
                else
                {
                    // none have been purchased yet, all the tickets remain
                    tickets = maxTickets;
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(tickets);
        }