Example #1
0
 public void EditMusicEventArtistTest()
 {
     using (var db = new EventsProjectContext())
     {
         var newMusicEvent = new MusicEvent()
         {
             VenueId     = "WMBLY",
             MusicId     = "_POP_",
             Artist      = "Beyonce",
             dateTime    = new DateTime(2020, 11, 07, 20, 00, 00),
             TicketsSold = 40000
         };
         db.MusicEvents.Add(newMusicEvent);
         db.SaveChanges();
         _crudManager.EditMusicEvent(newMusicEvent.MusicEventId, "Wembley Stadium", "Kasabian", new DateTime(2020, 11, 07, 20, 00, 00), 40000);
         var testMusicEventFixture = db.MusicEvents.Where(se => se.MusicEventId == newMusicEvent.MusicEventId).Select(s => new { s.Artist, s.MusicEventId }).FirstOrDefault();
         currentMusicEventId = testMusicEventFixture.MusicEventId;
         Assert.AreEqual(testMusicEventFixture.Artist, "Kasabian");
     }
 }
 public void RemoveSportEventTest()
 {
     using (var db = new EventsProjectContext())
     {
         var newSportEvent = new SportEvent()
         {
             VenueId     = "WMBLY",
             SportId     = "FTBAL",
             Fixture     = "Aston Villa vs Chelsea",
             dateTime    = new DateTime(2020, 11, 07, 20, 00, 00),
             TicketsSold = 40000
         };
         db.SportEvents.Add(newSportEvent);
         db.SaveChanges();
         var oldCount = db.SportEvents.Count();
         var sportId  = db.SportEvents.Where(se => se.Fixture == "Aston Villa vs Chelsea").FirstOrDefault();
         _crudManager.RemoveSportEvent(sportId.SportEventId);
         var newCount = db.SportEvents.Count();
         Assert.AreEqual(oldCount - 1, newCount);
     }
 }
Example #3
0
        // method to add a music event, ensuring tickets sold cannot exceed capacity

        public void AddMusicEvent(string venueId, string musicId, string artist, DateTime date, int ticketsSold)
        {
            using (var db = new EventsProjectContext())
            {
                var venueCapacity = db.Venues.Where(v => v.VenueId == venueId).Select(v => v.Capacity).FirstOrDefault();
                if (ticketsSold > venueCapacity)
                {
                    throw new ArgumentException("Tickets sold cannot exceed capacity");
                }
                var newMusicEvent = new MusicEvent()
                {
                    VenueId     = venueId,
                    MusicId     = musicId,
                    Artist      = artist,
                    dateTime    = date,
                    TicketsSold = ticketsSold
                };
                db.MusicEvents.Add(newMusicEvent);
                db.SaveChanges();
            }
        }
 public void SellingTicketsChangesNumberOfTicketsSoldTest()
 {
     using (var db = new EventsProjectContext())
     {
         var newEvent = new MusicEvent()
         {
             VenueId     = "WMBLY",
             MusicId     = "_POP_",
             Artist      = "A",
             dateTime    = new DateTime(2020, 11, 20, 20, 00, 00),
             TicketsSold = 10
         };
         db.MusicEvents.Add(newEvent);
         db.SaveChanges();
         var newArtistId = db.MusicEvents.Where(se => se.Artist == "A").Select(se => se.MusicEventId).FirstOrDefault();
         _crudManager.SellMusicTickets(100, "Wembley Stadium", newEvent);
         var testTicketsSold = db.MusicEvents.Where(se => se.MusicEventId == newArtistId).Select(se => se.TicketsSold).FirstOrDefault();
         Assert.AreEqual(110, testTicketsSold);
         currentMusicEventId = db.MusicEvents.Where(me => me.Artist == "A").Select(me => me.MusicEventId).FirstOrDefault();
     }
 }
 public void SellingTicketsChangesNumberOfTicketsSoldTest()
 {
     using (var db = new EventsProjectContext())
     {
         var newEvent = new SportEvent()
         {
             VenueId     = "WMBLY",
             SportId     = "FTBAL",
             Fixture     = "A vs B",
             dateTime    = new DateTime(2020, 11, 20, 20, 00, 00),
             TicketsSold = 10
         };
         db.SportEvents.Add(newEvent);
         db.SaveChanges();
         var newFixtureId = db.SportEvents.Where(se => se.Fixture == "A vs B").Select(se => se.SportEventId).FirstOrDefault();
         _crudManager.SellSportTickets(100, "Wembley Stadium", newEvent);
         var testTicketsSold = db.SportEvents.Where(se => se.SportEventId == newFixtureId).Select(se => se.TicketsSold).FirstOrDefault();
         Assert.AreEqual(110, testTicketsSold);
         currentSportEventId = db.SportEvents.Where(me => me.Fixture == "A vs B").Select(me => me.SportEventId).FirstOrDefault();
     }
 }
Example #6
0
 // method to edit a sport event, ensuring tickets sold cannot exceed capacity
 public void EditSportEvent(int sportEventId, string venueName, string fixture, DateTime date, int ticketsSold)
 {
     using (var db = new EventsProjectContext())
     {
         if (ticketsSold > db.Venues.Where(v => v.VenueName == venueName).Select(v => v.Capacity).FirstOrDefault())
         {
             throw new ArgumentException("Tickets sold exceeds events capacity");
         }
         try
         {
             SelectedSportEvent             = db.SportEvents.Where(se => se.SportEventId == sportEventId).FirstOrDefault();
             SelectedSportEvent.VenueId     = db.Venues.Where(v => v.VenueName == venueName).Select(v => v.VenueId).FirstOrDefault();
             SelectedSportEvent.Fixture     = fixture;
             SelectedSportEvent.dateTime    = date;
             SelectedSportEvent.TicketsSold = ticketsSold;
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
     }
 }
Example #7
0
 public void RemoveMusicEventTest()
 {
     using (var db = new EventsProjectContext())
     {
         var newMusicEvent = new MusicEvent()
         {
             VenueId     = "WMBLY",
             MusicId     = "_POP_",
             Artist      = "Beyonce",
             dateTime    = new DateTime(2020, 11, 07, 20, 00, 00),
             TicketsSold = 40000
         };
         db.MusicEvents.Add(newMusicEvent);
         db.SaveChanges();
         var oldCount = db.MusicEvents.Count();
         var musicId  = db.MusicEvents.Where(se => se.Artist == "Beyonce").FirstOrDefault();
         _crudManager.RemoveMusicEvent(musicId.MusicEventId);
         var newCount = db.MusicEvents.Count();
         //currentSportEventId = sportId.SportEventId;
         Assert.AreEqual(oldCount - 1, newCount);
     }
 }
Example #8
0
 // method to add a sport event, ensuring tickets sold cannot exceed the capacity of the venue
 public void AddSportEvent(string venueId, string sportId, string fixture, DateTime date, int ticketsSold)
 {
     using (var db = new EventsProjectContext())
     {
         var venueCapacity = db.Venues.Where(v => v.VenueId == venueId).Select(v => v.Capacity).FirstOrDefault();
         if (ticketsSold > venueCapacity)
         {
             throw new ArgumentException("Tickets sold cannot exceed capacity");
         }
         else
         {
             var newSportEvent = new SportEvent()
             {
                 VenueId     = venueId,
                 SportId     = sportId,
                 Fixture     = fixture,
                 dateTime    = date,
                 TicketsSold = ticketsSold
             };
             db.SportEvents.Add(newSportEvent);
             db.SaveChanges();
         }
     }
 }