public void Test_Delete_DeletesVenueFromDatabase() { //Arrange string name1 = "Emporium"; Venue testVenue1 = new Venue(name1); testVenue1.Save(); string name2 = "Orange Peel"; Venue testVenue2 = new Venue(name2); testVenue2.Save(); Band testBand1 = new Band("Kendrick Lamar", testVenue1.GetId()); testBand1.Save(); Band testBand2 = new Band("Moldy Peaches", testVenue2.GetId()); testBand2.Save(); //Act testVenue1.Delete(); List <Venue> resultVenues = Venue.GetAll(); List <Venue> testVenueList = new List <Venue> { testVenue2 }; //Assert Assert.Equal(testVenueList, resultVenues); }
public void Delete_DeletesVenueAssociationsFromDatabase_VenueList() { //Arrange Band testBand = new Band("Kendrick Lamar"); testBand.Save(); string testName = "Orange Peel"; Venue testVenue = new Venue(testName); testVenue.Save(); //Act testVenue.AddBand(testBand); testVenue.Delete(); List <Venue> resultBandVenues = testBand.GetVenues(); List <Venue> testBandVenues = new List <Venue> { }; //Assert Assert.Equal(testBandVenues, resultBandVenues); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; //homepage with links to view all bands and all venues Get["/bands"] = _ => { List <Band> AllBands = Band.GetAll(); return(View["bands.cshtml", AllBands]); }; //page view all bands Get["/venues"] = _ => { List <Venue> AllVenues = Venue.GetAll(); return(View["venues.cshtml", AllVenues]); }; //page view all venues Get["/venues/new"] = _ => { return(View["venues_form.cshtml"]); }; Get["/bands/new"] = _ => { return(View["bands_form.cshtml"]); }; //returns form to add new band Post["/bands/new"] = _ => { Band newBand = new Band(Request.Form["band-name"]); newBand.Save(); List <Band> AllBands = Band.GetAll(); return(View["bands.cshtml", AllBands]); }; //posts from form adding new band Get["/venues/new"] = _ => { return(View["venues_form.cshtml"]); }; //returns form to add new band Post["/venues/new"] = _ => { Venue newVenue = new Venue(Request.Form["venue-name"]); newVenue.Save(); List <Venue> AllVenues = Venue.GetAll(); return(View["venues.cshtml", AllVenues]); }; //posts from form adding new venue Get["/bands/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Band SelectedBand = Band.Find(parameters.id); List <Venue> BandVenues = SelectedBand.GetVenues(); List <Venue> AllVenues = Venue.GetAll(); model.Add("band", SelectedBand); model.Add("bandVenues", BandVenues); model.Add("allVenues", AllVenues); return(View["band.cshtml", model]); }; //returns individual instance of band Get["/venues/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Venue SelectedVenue = Venue.Find(parameters.id); List <Band> VenueBands = SelectedVenue.GetBands(); List <Band> AllBands = Band.GetAll(); model.Add("venue", SelectedVenue); model.Add("venueBands", VenueBands); model.Add("allBands", AllBands); return(View["venue.cshtml", model]); }; //returns individual instance of venue Post["/band/{id}/add_venue"] = parameters => { Venue venue = Venue.Find(Request.Form["venue-id"]); Band band = Band.Find(Request.Form["band-id"]); band.AddVenue(venue); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> bandVenues = band.GetVenues(); List <Venue> allVenues = Venue.GetAll(); model.Add("band", band); model.Add("bandVenues", bandVenues); model.Add("allVenues", allVenues); return(View["index.cshtml", model]); }; //posts from form adding venue Post["/venue/{id}/add_band"] = parameters => { Venue venue = Venue.Find(Request.Form["venue-id"]); Band band = Band.Find(Request.Form["band-id"]); venue.AddBand(band); Dictionary <string, object> model = new Dictionary <string, object>(); Venue SelectedVenue = Venue.Find(parameters.id); List <Band> VenueBands = SelectedVenue.GetBands(); List <Band> AllBands = Band.GetAll(); model.Add("venue", SelectedVenue); model.Add("venueBands", VenueBands); model.Add("allBands", AllBands); return(View["venue.cshtml", model]); }; //posts from form adding band to venue page Get["/venue/edit/{id}"] = parameters => { Venue SelectedVenue = Venue.Find(parameters.id); return(View["venue_edit.cshtml", SelectedVenue]); }; //edit individual venue Patch["/venue/edit/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Venue SelectedVenue = Venue.Find(parameters.id); SelectedVenue.Update(Request.Form["venue-name"]); List <Band> VenueBands = SelectedVenue.GetBands(); List <Band> AllBands = Band.GetAll(); model.Add("venue", SelectedVenue); model.Add("venueBands", VenueBands); model.Add("allBands", AllBands); return(View["venue.cshtml", model]); }; //posts from editing individual venue Get["/venue/delete/{id}"] = parameters => { Venue SelectedVenue = Venue.Find(parameters.id); return(View["venue_delete.cshtml", SelectedVenue]); }; //delete individual venue Delete["/venue/delete/{id}"] = parameters => { Venue SelectedVenue = Venue.Find(parameters.id); SelectedVenue.Delete(); List <Venue> AllVenues = Venue.GetAll(); return(View["venues.cshtml", AllVenues]); }; //delete individual venue }