public void AddMusicTypeTest() { using (var db = new EventsProjectContext()) { var countBefore = db.Musics.Count(); _crudManager.AddMusicType("HPHOP", "Hip Hop"); var countAfter = db.Musics.Count(); Assert.AreEqual(countBefore + 1, countAfter); } }
// metgod to add the event private void AddEvent_Click(object sender, RoutedEventArgs e) { try { var artist = FixtureGenreInfo.Text; var ticketsSold = Int32.Parse(TicketsSoldInfo.Text); // converting the entered date and time into correct format for DateTime object int year = DateTime.Parse(DateInfo.Text).Year; var month = DateTime.Parse(DateInfo.Text).Month; var day = DateTime.Parse(DateInfo.Text).Day; var hour = DateTime.Parse(TimeInfo.Text).Hour; var min = DateTime.Parse(TimeInfo.Text).Minute; var dateTime = new DateTime(year, month, day, hour, min, 0); // catch blocks to ensure everything submitted is valid if (SportMusicBox.SelectedItem != null) { if (TypeBox.SelectedItem == null) { var id = NewGenreIdInfo.Text; var info = NewGenreInfo.Text; if (SportMusicBox.SelectedItem.ToString() == "Music") { _crudManager.AddMusicType(id, info); var venue = _crudManager.SelectedVenue; try { _crudManager.AddMusicEvent(venue.VenueId, id, artist, dateTime, ticketsSold); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (SportMusicBox.SelectedItem.ToString() == "Sport") { _crudManager.AddSportType(id, info); var venue = _crudManager.SelectedVenue; try { _crudManager.AddSportEvent(venue.VenueId, id, artist, dateTime, ticketsSold); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } else if (SportMusicBox.SelectedItem.ToString() == "Music") { var venue = _crudManager.SelectedVenue; var music = _crudManager.SelectedMusic; _crudManager.AddMusicEvent(venue.VenueId, music.MusicId, artist, dateTime, ticketsSold); this.Close(); } else if (SportMusicBox.SelectedItem.ToString() == "Sport") { var venue = _crudManager.SelectedVenue; var sport = _crudManager.SelectedSport; _crudManager.AddSportEvent(venue.VenueId, sport.SportId, artist, dateTime, ticketsSold); this.Close(); } } } catch (Exception ex) { MessageBox.Show("Input was invalid"); } }