Beispiel #1
0
        public IActionResult OnPostAddBooking(int concertId, int participantId)
        {
            Concert     concert     = FestivalManager.Calendar.GetConcert(concertId);
            Participant participant = FestivalManager.GetParticipant(participantId);

            concert.MakeBooking(participant, FestivalManager);
            return(RedirectToPage("./ParticipantPage", new { id = participantId }));
        }
        public IActionResult OnPostBookSpot(int id)
        {
            var claimTicketID = HttpContext.User.Claims.Where(c => c.Type == "TicketID").Select(t => t.Value).First();

            Concert c = FestivalManager.Calendar.GetConcert(id);

            c.MakeBooking(FestivalManager.GetParticipants().Where(p => p.Ticket?.TicketNumber == claimTicketID).First(), FestivalManager);
            return(RedirectToPage("./ParticipantArtist", new { id = id }));
        }
Beispiel #3
0
        public void MakeBooking_CannotMakeBookingWhenParticipantCannotMakeBooking()
        {
            //Arrange
            Concert concert             = GetConcertAtMaxCapacity();
            Booking expected            = null;
            var     mock                = new Mock <Participant>();
            var     mockFestivalManager = new Mock <IFestivalManager>();

            mock.Setup(p => p.CanMakeBookingAt(concert, mockFestivalManager.Object)).Returns(false); //Defining other argument in if-statement as always false

            //Act
            Booking result = concert.MakeBooking(mock.Object, mockFestivalManager.Object);

            //Assert
            Assert.Equal(expected, result);
        }
        public IActionResult OnPostNewBooking(int id)
        {
            var claimTicketID = HttpContext.User.Claims.Where(c => c.Type == "TicketID").Select(t => t.Value).First();

            Concert     concert = FestivalManager.Calendar.GetConcert(id);
            Participant p       = FestivalManager.GetParticipants().Where(p => p.Ticket?.TicketNumber == claimTicketID).First();

            List <Concert> overlappedConcerts = p.GetParticipantBookings(FestivalManager).Select(b => b.Concert).Where(c => concert.Start <c.End && concert.End> c.Start).ToList();

            foreach (Concert overlap in overlappedConcerts)
            {
                overlap.RemoveBooking(p);
            }

            concert.MakeBooking(p, FestivalManager);
            return(RedirectToPage("./ParticipantArtist", new { id = id }));
        }
Beispiel #5
0
        public void MakeBooking_CanMakeBookingWhenNotAtMaxCapacity()
        {
            //Arrange
            Concert concert             = GetConcertWithSpaceForTwo();
            var     mock                = new Mock <Participant>();
            var     mockFestivalManager = new Mock <IFestivalManager>();

            mock.Setup(p => p.CanMakeBookingAt(concert, mockFestivalManager.Object)).Returns(true); //Defining other argument in if-statement as always true
            var expected = (mock.Object, concert);

            //Act
            Booking resultBooking = concert.MakeBooking(mock.Object, mockFestivalManager.Object);
            var     result        = (resultBooking?.Participant, resultBooking?.Concert);

            //Assert
            Assert.Equal(expected, result);
        }