Exemplo n.º 1
0
        public void ShowExists()
        {
            Show show = showRepository.FindOne("1");

            Assert.AreEqual(show.Venue, "Sala Polivalenta");
            Assert.AreEqual(show.ArtistName, "Twenty One Pilots");
            Assert.AreEqual(show.TotalTickets, 1600);
        }
Exemplo n.º 2
0
 public void buyTickets(String idShow, String buyer, int quantity)
 {
     for (int i = 0; i < quantity; i++)
     {
         Show s      = _showRepository.FindOne(idShow);
         int  number = s.TotalTickets - s.RemainingTickets + 1;
         _ticketRepository.Save(new Ticket(idShow, number, buyer));
         s.RemainingTickets = s.RemainingTickets - 1;
         _showRepository.Update(s);
     }
 }
Exemplo n.º 3
0
        public void BuyTickets(int showId, int quantity, String purchaserName)
        {
            Show show = showRepo.FindOne(showId);

            if (show.AvailableTicketsNumber < quantity)
            {
                throw new InvalidPurchaseException(quantity, showId);
            }
            else
            {
                ticketRepo.Save(new Ticket(showId, purchaserName, quantity));
                show.AvailableTicketsNumber = show.AvailableTicketsNumber - quantity;
                show.SoldTicketsNumber      = show.SoldTicketsNumber + quantity;
                showRepo.Update(show);
            }
        }
Exemplo n.º 4
0
        public void SellTickets(Ticket ticket)
        {
            Show show = showRepository.FindOne(ticket.ShowId);

            if (show.AvailableTicketsNumber < ticket.Number)
            {
                throw new InvalidPurchaseException(ticket.Number, ticket.ShowId);
            }
            else
            {
                ticketRepository.Save(ticket);
                show.AvailableTicketsNumber = show.AvailableTicketsNumber - ticket.Number;
                show.SoldTicketsNumber      = show.SoldTicketsNumber + ticket.Number;
                showRepository.Update(show);
                Console.WriteLine("Notifying others about the sell");
                foreach (var each in loggedClients)
                {
                    Console.WriteLine("Notifying user " + each.Key);
                    Task.Run(() => each.Value.TicketSold(ticket));
                }
            }
        }