public void Test_GetBands() { Venue testVenue = new Venue("123 Fakestreet", "Fakename Center"); testVenue.Save(); Band testBand = new Band("Pazz", "Jeff and the Baboons"); testBand.Save(); testBand.AddPerformance(testVenue.id); Assert.Equal(testBand.id, testVenue.GetBands()[0].id); }
public void Test_AddBand_AddsBandToVenue() { Band testBand = new Band("Frets on Fire"); testBand.Save(); Venue testVenue = new Venue("Shatter Dome"); testVenue.Save(); testVenue.AddBand(testBand); List<Band> testList = new List<Band>{testBand}; List<Band> result = testVenue.GetBands(); Assert.Equal(testList, result); }
public void Test_AddBand_AddsBandToVenue() { //Arrange Venue testVenue = new Venue("El Corazon"); testVenue.Save(); Band testBand = new Band("The Loud Mouths"); testBand.Save(); Band testBand2 = new Band("The People With Guitars "); testBand2.Save(); //Act testVenue.AddBand(testBand); testVenue.AddBand(testBand2); List<Band> result = testVenue.GetBands(); List<Band> testList = new List<Band>{testBand, testBand2}; //Assert Assert.Equal(testList, result); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/venues"] = _ => { List <Venue> AllVenues = Venue.GetAll(); return(View["venues.cshtml", AllVenues]); }; Get["/bands"] = _ => { List <Band> AllBands = Band.GetAll(); return(View["bands.cshtml", AllBands]); }; Get["/venues/new"] = _ => { return(View["venues_form.cshtml"]); }; Post["/venues/new"] = _ => { Venue newVenue = new Venue(Request.Form["venue-description"]); newVenue.Save(); newVenue.Update(newVenue.ForceCapital(newVenue.GetName())); return(View["success.cshtml"]); }; Get["/bands/new"] = _ => { return(View["bands_form.cshtml"]); }; Post["/bands/new"] = _ => { Band newBand = new Band(Request.Form["band-name"]); newBand.Save(); newBand.Update(newBand.ForceCapital(newBand.GetName())); return(View["success.cshtml"]); }; 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]); }; 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]); }; Post["venue/add_band"] = _ => { Band band = Band.Find(Request.Form["band-id"]); Venue venue = Venue.Find(Request.Form["venue-id"]); venue.AddBand(band); return(View["success.cshtml"]); }; Post["band/add_venue"] = _ => { Band band = Band.Find(Request.Form["band-id"]); Venue venue = Venue.Find(Request.Form["venue-id"]); band.AddVenue(venue); return(View["success.cshtml"]); }; Get["venues/update/{id}"] = parameters => { Venue foundVenue = Venue.Find(parameters.id); return(View["venue_update.cshtml", foundVenue]); }; Patch["venues/update/{id}"] = parameters => { Venue foundVenue = Venue.Find(parameters.id); foundVenue.Update(Request.Form["new-description"]); return(View["success.cshtml"]); }; Get["bands/update/{id}"] = parameters => { Band foundBand = Band.Find(parameters.id); return(View["band_update.cshtml", foundBand]); }; Patch["bands/update/{id}"] = parameters => { Band foundBand = Band.Find(parameters.id); foundBand.Update(Request.Form["new-description"]); return(View["success.cshtml"]); }; Delete["band/delete/{id}"] = parameters => { Band foundBand = Band.Find(parameters.id); foundBand.Delete(); return(View["success.cshtml"]); }; Delete["venue/delete/{id}"] = parameters => { Venue foundVenue = Venue.Find(parameters.id); foundVenue.Delete(); return(View["success.cshtml"]); }; Delete["venues/delete_all"] = _ => { Venue.DeleteAll(); return(View["success.cshtml"]); }; }
public HomeModule() { Get["/"] = _ => View["index.cshtml"]; Get["/venues"] = _ => { List <Venue> AllVenues = Venue.GetAll(); return(View["venues.cshtml", AllVenues]); }; Get["/bands"] = _ => { List <Band> AllBands = Band.GetAll(); return(View["bands.cshtml", AllBands]); }; Get["/venues/new"] = _ => { return(View["venues_form.cshtml"]); }; Post["/venues/new"] = _ => { Venue newVenue = new Venue(Request.Form["venue-name"]); newVenue.Save(); return(View["venues.cshtml", Venue.GetAll()]); }; Get["/bands/new"] = _ => { List <Venue> AllVenues = Venue.GetAll(); return(View["bands_form.cshtml", AllVenues]); }; Post["/bands/new"] = _ => { Band newBand = new Band(Request.Form["band-name"], Request.Form["band-genre"], Request.Form["band-song"]); newBand.Save(); return(View["bands.cshtml", Band.GetAll()]); }; Get["/venues/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); var SelectedVenue = Venue.Find(parameters.id); var 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]); }; 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]); }; Post["/band/add_venue"] = _ => { Venue venue = Venue.Find(Request.Form["venue-id"]); Band band = Band.Find(Request.Form["band-id"]); band.AddVenue(venue); return(View["venue-list.cshtml", band.GetVenues()]); }; Post["/venue/add_band"] = _ => { Venue venue = Venue.Find(Request.Form["venue-id"]); Band band = Band.Find(Request.Form["band-id"]); venue.AddBand(band); return(View["band-list.cshtml", venue.GetBands()]); }; Patch["/venue/edit/{id}"] = parameters => { Venue SelectedVenue = Venue.Find(parameters.id); SelectedVenue.UpdateVenues(Request.Form["new-venue-name"]); return(View["venues.cshtml", Venue.GetAll()]); }; Get["/bands/detail/{id}"] = parameters => { Band band = Band.Find(parameters.id); return(View["band-detail.cshtml", band]); }; Delete["/venues/{id}"] = parameters => { Venue targetVenue = Venue.Find(parameters.id); targetVenue.Delete(); return(View["venues.cshtml", Venue.GetAll()]); }; Delete["/bands/{id}"] = parameters => { Band targetBand = Band.Find(parameters.id); targetBand.Delete(); return(View["bands.cshtml", Band.GetAll()]); }; Post["/venues/delete"] = _ => { Venue.DeleteAll(); return(View["index.cshtml"]); }; Post["/bands/delete"] = _ => { Band.DeleteAll(); return(View["index.cshtml"]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/bands"] = _ => { List <Band> allBands = Band.GetAll(); return(View["bands.cshtml", allBands]); }; Get["/venues"] = _ => { List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Get["/venues/new"] = _ => { return(View["venue_form.cshtml"]); }; Get["/bands/new"] = _ => { return(View["band_form.cshtml"]); }; Post["/venues/new"] = _ => { string venueName = Request.Form["venue-name"]; string venueAddress = Request.Form["venue-address"]; Venue newVenue = new Venue(venueName, venueAddress); newVenue.Save(); return(View["venue.cshtml", newVenue]); }; Post["/bands/new"] = _ => { string bandName = Request.Form["band-name"]; string bandType = Request.Form["band-type"]; Band newBand = new Band(bandName, bandType); newBand.Save(); return(View["band.cshtml", newBand]); }; Get["/band/{id}/venues/add"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> (); Band selectedBand = Band.Find(parameters.id); List <Venue> currentVenues = selectedBand.GetVenues(); List <Venue> allVenues = Venue.GetAll(); List <Venue> availableVenues = new List <Venue> { }; foreach (Venue venue in allVenues) { // If a venue is already in the band it will return an index of 0 or above. if (currentVenues.IndexOf(venue) < 0) { availableVenues.Add(venue); } } model.Add("band", selectedBand); model.Add("available-venues", availableVenues); return(View["AddVenueToBand.cshtml", model]); }; Get["/venues/{id}/bands/add"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> (); Venue selectedVenue = Venue.Find(parameters.id); List <Band> currentBands = selectedVenue.GetBands(); List <Band> allBands = Band.GetAll(); List <Band> availableBands = new List <Band> { }; foreach (Band band in allBands) { // If the band is already enrolled in a venue it will return an index of 0 or above. if (currentBands.IndexOf(band) < 0) { availableBands.Add(band); } } model.Add("venue", selectedVenue); model.Add("available-bands", availableBands); return(View["AddBandToVenue.cshtml", model]); }; Get["/venue/{venue_id}"] = parameters => { Venue selectedVenue = Venue.Find(parameters.venue_id); return(View["venue.cshtml", selectedVenue]); }; Get["/band/{band_id}"] = parameters => { Band selectedBand = Band.Find(parameters.band_id); return(View["band.cshtml", selectedBand]); }; Post["/band/{id}/venues/added"] = parameters => { int venueId = int.Parse(Request.Form["venue-id"]); Venue selectedVenue = Venue.Find(venueId); Band selectedBand = Band.Find(parameters.id); selectedBand.AddVenue(selectedVenue); return(View["venue_added.cshtml", selectedBand]); }; Post["/venue/{id}/bands/added"] = parameters => { int bandId = int.Parse(Request.Form["band-id"]); Band selectedBand = Band.Find(bandId); Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.AddBand(selectedBand); return(View["band_added.cshtml", selectedVenue]); }; Get["/venues/{id}/update"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); return(View["update.cshtml", selectedVenue]); }; Patch["/venues/{id}/update"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); string newName = Request.Form["new-name"]; string newAddress = Request.Form["new-address"]; selectedVenue.Update(newName, newAddress); return(View["success.cshtml", selectedVenue]); }; Get["/venues/{id}/delete"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); return(View["delete.cshtml", selectedVenue]); }; Delete["/venues/{id}/delete"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.Delete(); return(View["deleted.cshtml"]); }; }
public HomeModule() { Get["/"] = _ => { Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; Post["/band_added"] = _ => { Band newBand = new Band(Request.Form["band-name"]); newBand.Save(); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; Post["/venue_added"] = _ => { Venue newVenue = new Venue(Request.Form["venue-name"]); newVenue.Save(); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; Get["/band/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Band selectedBand = Band.Find(parameters.id); List <Venue> bandVenues = selectedBand.GetVenues(); model.Add("band", selectedBand); model.Add("venues", bandVenues); return(View["band.cshtml", model]); }; Get["/venue/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Venue selectedVenue = Venue.Find(parameters.id); List <Band> venueBands = selectedVenue.GetBands(); model.Add("venue", selectedVenue); model.Add("bands", venueBands); return(View["venue.cshtml", model]); }; Patch["/venue/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.Update(Request.Form["rename"]); List <Band> venueBands = selectedVenue.GetBands(); model.Add("venue", selectedVenue); model.Add("bands", venueBands); return(View["venue.cshtml", model]); }; Delete["/deleted/{id}"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.DeleteAssociations(); selectedVenue.Delete(); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; Post["/performance_added"] = _ => { Performance newPerformance = new Performance(Request.Form["performance-venue"], Request.Form["performance-band"], Request.Form["performance-date"]); newPerformance.Save(); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; Delete["/delete_all"] = _ => { Venue.DeleteAll(); Band.DeleteAll(); Performance.DeleteAll(); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; }
public HomeModule() { Get["/"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> { }; model.Add("allVenues", Venue.GetAll()); model.Add("allBands", Band.GetAll()); return(View["index.cshtml", model]); }; Get["/venues/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue venue = Venue.Find(parameters.id); model.Add("allVenues", Venue.GetAll()); model.Add("venue", venue); model.Add("venues-bands", venue.GetBands()); model.Add("allBands", Band.GetAll()); return(View["index.cshtml", model]); }; Get["/venues/{venId}/bands/{bandId}/events"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.venId); Band selectedBand = Band.Find(parameters.bandId); model.Add("venue", selectedVenue); model.Add("allVenues", Venue.GetAll()); model.Add("show-venue", selectedVenue); model.Add("venues-bands", selectedVenue.GetBands()); model.Add("events", selectedVenue.GetEvents(selectedBand)); model.Add("allBands", Band.GetAll()); return(View["index.cshtml", model]); }; Get["/venues/new"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> { }; model.Add("bands", Band.GetAll()); model.Add("add-venue", null); return(View["form.cshtml", model]); }; Post["/venues/new"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> { }; model.Add("bands", Band.GetAll()); Venue newVenue = new Venue(Request.Form["name"], Request.Form["capacity"]); newVenue.Save(); if (Request.Form["band"] != "") { Band selectedBand = Band.Find(Request.Form["band"]); newVenue.AddBand(selectedBand, Request.Form["date"]); model.Add("band", Band.Find(Request.Form["band"])); } model.Add("new-venue", newVenue); return(View["form.cshtml", model]); }; Get["/venues/{id}/update"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.id); model.Add("venue", selectedVenue); model.Add("bands", selectedVenue.GetBands()); model.Add("show", "update-form"); model.Add("otherBands", selectedVenue.GetOtherBands()); return(View["update_form.cshtml", model]); }; Patch["/venues/{id}/update"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.id); string bands = Request.Form["band"]; if (bands != null) { string[] values = bands.Split(','); foreach (string bandId in values) { selectedVenue.DeleteBandRelationship(Band.Find(int.Parse(bandId))); } } selectedVenue.Update(Request.Form["name"]); model.Add("venue", selectedVenue); model.Add("bands", selectedVenue.GetBands()); model.Add("show", "update-info"); return(View ["update_form.cshtml", model]); }; Get["/bands/new"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> { }; model.Add("new-band", null); model.Add("venues", Venue.GetAll()); return(View["form.cshtml", model]); }; Post["/bands/new"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> { }; Band newBand = new Band(Request.Form["name"]); newBand.Save(); if (Request.Form["venue-selected"] != "") { Venue selectedVenue = Venue.Find(Request.Form["venue-choose"]); newBand.AddVenue(selectedVenue, Request.Form["date"]); model.Add("venue-selected", selectedVenue); } model.Add("allVenues", Venue.GetAll()); model.Add("allBands", Band.GetAll()); return(View["index.cshtml", model]); }; Delete["/venues/{id}/delete"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.DeleteSingleVenue(); string name = selectedVenue.Name; model.Add("allVenues", Venue.GetAll()); model.Add("allBands", Band.GetAll()); model.Add("delete-confirm", name); return(View["index.cshtml", model]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/bands"] = _ => { List <Band> allBands = Band.GetAll(); return(View["bands.cshtml", allBands]); }; Get["/band/new"] = _ => { return(View["new_band.cshtml"]); }; Post["/band/new"] = _ => { Band newBand = new Band(Request.Form["band-name"]); newBand.Save(); return(View["new_band.cshtml", newBand]); }; Get["/venues"] = _ => { List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Get["/venue/new"] = _ => { return(View["new_venue.cshtml"]); }; Post["/venue/new"] = _ => { Venue newVenue = new Venue(Request.Form["venue-name"]); newVenue.Save(); return(View["new_venue.cshtml", newVenue]); }; Get["/band/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Band foundBand = Band.Find(parameters.id); List <Venue> venues = foundBand.GetVenues(); List <Venue> allVenues = Venue.GetAll(); model.Add("current-band", foundBand); model.Add("venues-in-band", venues); model.Add("all-venues", allVenues); return(View["band.cshtml", model]); }; Post["/band/add_venue"] = _ => { Band band = Band.Find(Request.Form["band-id"]); Venue venue = Venue.Find(Request.Form["venue-id"]); band.AddVenue(venue); return(View["success.cshtml"]); }; Get["/venue/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Venue foundVenue = Venue.Find(parameters.id); List <Band> bands = foundVenue.GetBands(); List <Band> allBands = Band.GetAll(); model.Add("current-venue", foundVenue); model.Add("bands-in-venue", bands); model.Add("all-bands", allBands); return(View["venue.cshtml", model]); }; Post["/venue/add_band"] = _ => { Venue newVenue = Venue.Find(Request.Form["venue-id"]); Band newBand = Band.Find(Request.Form["band-id"]); newVenue.AddBand(newBand); return(View["success.cshtml"]); }; Get["/venue/delete/{id}"] = parameters => { Venue newVenue = Venue.Find(parameters.id); return(View["venue_delete.cshtml", newVenue]); }; Delete["/venue/delete/{id}"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.Delete(); return(View["success.cshtml"]); }; Get["venue/edit/{id}"] = parameters => { Venue SelectedVenue = Venue.Find(parameters.id); return(View["venue_edit.cshtml", SelectedVenue]); }; Patch["/venue/edit/{id}"] = parameters => { Venue SelectedVenue = Venue.Find(parameters.id); SelectedVenue.Update(Request.Form["venue-name"]); return(View["success.cshtml"]); }; }
public HomeModule() { Get["/"] = _ => View["index.cshtml"]; Get["/venues"] = _ => { List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Get["/bands"] = _ => { List <Band> allBands = Band.GetAll(); return(View["bands.cshtml", allBands]); }; Get["/venues/new"] = _ => { return(View["venue_form.cshtml"]); }; Get["/bands/new"] = _ => { return(View["band_form.cshtml"]); }; Get["/bands/new/members"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> { }; model.Add("part2", true); model.Add("members", Request.Query["members-number"]); return(View["band_form.cshtml", model]); }; Post["/bands/new"] = _ => { Band newBand = new Band(Request.Form["band-name"], Request.Form["members"]); newBand.Save(); string membersValues = Request.Form["member-name"]; if (membersValues != null) { string[] members = membersValues.Split(','); foreach (string member in members) { Member newMember = new Member(member, newBand.Id); newMember.Save(); } } List <Band> allBands = Band.GetAll(); return(View["bands.cshtml", allBands]); }; Post["/venues/new"] = _ => { Venue newVenue = new Venue(Request.Form["venue-name"], Request.Form["venue-address"]); newVenue.Save(); List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Get["/venues/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.id); model.Add("selected-venue", selectedVenue); model.Add("venue-bands", selectedVenue.GetBands()); model.Add("all-bands", Band.GetAll()); return(View["venue.cshtml", model]); }; Get["/bands/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Band selectedBand = Band.Find(parameters.id); model.Add("selected-band", selectedBand); model.Add("band-venues", selectedBand.GetVenues()); model.Add("all-venues", Venue.GetAll()); return(View["band.cshtml", model]); }; Get["/venues/{id}/bands/new"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.id); model.Add("selected-venue", selectedVenue); model.Add("venue-bands", selectedVenue.GetBands()); model.Add("all-bands", Band.GetAll()); return(View["add_band.cshtml", model]); }; Post["/venues/{id}/bands/new"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.id); Band selectedBand = Band.Find(Request.Form["band-select"]); selectedVenue.AddBand(selectedBand); model.Add("selected-venue", selectedVenue); model.Add("venue-bands", selectedVenue.GetBands()); model.Add("all-bands", Band.GetAll()); return(View["venue.cshtml", model]); }; Get["/bands/{id}/venues/new"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Band selectedBand = Band.Find(parameters.id); model.Add("selected-band", selectedBand); model.Add("band-venues", selectedBand.GetVenues()); model.Add("all-venues", Venue.GetAll()); return(View["add_venue.cshtml", model]); }; Post["/bands/{id}/venues/new"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Band selectedBand = Band.Find(parameters.id); Venue selectedVenue = Venue.Find(Request.Form["venue-select"]); selectedBand.AddVenue(selectedVenue); model.Add("selected-band", selectedBand); model.Add("band-venues", selectedBand.GetVenues()); model.Add("all-venues", Venue.GetAll()); return(View["band.cshtml", model]); }; Delete["/bands/delete"] = _ => { Band.DeleteAll(); List <Band> allBands = Band.GetAll(); return(View["bands.cshtml", allBands]); }; Delete["/venues/delete"] = _ => { Venue.DeleteAll(); List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Get["/venues/{id}/edit"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.id); model.Add("selected-venue", selectedVenue); model.Add("edit", true); return(View["venue_form.cshtml", model]); }; Post["/venues/{id}/edit"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.Update(Request.Form["venue-name-edit"], Request.Form["venue-address-edit"]); model.Add("selected-venue", selectedVenue); model.Add("venue-bands", selectedVenue.GetBands()); model.Add("all-bands", Band.GetAll()); return(View["venue.cshtml", model]); }; Get["/venues/{id}/bands/delete"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.id); model.Add("selected-venue", selectedVenue); model.Add("venue-bands", selectedVenue.GetBands()); model.Add("all-bands", Band.GetAll()); model.Add("list-edit", true); return(View["venue.cshtml", model]); }; Delete["/venues/{id}/bands/delete"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Venue selectedVenue = Venue.Find(parameters.id); string bandIds = Request.Form["band"]; if (bandIds != null) { string[] values = bandIds.Split(','); foreach (string id in values) { Band toDelete = Band.Find(int.Parse(id)); selectedVenue.DeleteBandRelationship(toDelete); } } model.Add("selected-venue", selectedVenue); model.Add("venue-bands", selectedVenue.GetBands()); model.Add("all-bands", Band.GetAll()); return(View["venue.cshtml", model]); }; Delete["/venues/{id}/delete"] = parameters => { Venue toDelete = Venue.Find(parameters.id); toDelete.Delete(); List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; }
public void Test_GetBands_ReturnsAllBandBands() { Venue testVenue = new Venue("Shatter Dome"); testVenue.Save(); Band testBand1 = new Band("Frets on Fire"); testBand1.Save(); Band testBand2 = new Band("Crimson Typhoon and the Knife Heads"); testBand2.Save(); testVenue.AddBand(testBand1); testVenue.AddBand(testBand2); List<Band> testList = new List<Band> {testBand1, testBand2}; List<Band> result = testVenue.GetBands(); Assert.Equal(testList, result); }
public HomeModule() { Get["/"] = _ => { Dictionary <string, object> model = new Dictionary <string, object>(); List <Band> allBands = Band.GetAll(); List <Venue> allVenues = Venue.GetAll(); model.Add("bands", allBands); model.Add("venues", allVenues); return(View["index.cshtml", model]); }; Get["/band/new"] = _ => { return(View["new-band-form.cshtml"]); }; Get["/venue/new"] = _ => { return(View["new-venue-form.cshtml"]); }; Post["/band/new"] = _ => { Band newBand = new Band(Request.Form["bandName"]); newBand.Save(); return(View["created.cshtml", newBand]); }; Post["/venue/new"] = _ => { Venue newVenue = new Venue(Request.Form["venueName"]); newVenue.Save(); return(View["created.cshtml", newVenue]); }; Get["/band/{id}"] = parameters => { Band currentBand = Band.Find(parameters.id); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("band", currentBand); model.Add("bandVenues", currentBand.GetVenues()); model.Add("venues", Venue.GetAll()); return(View["band.cshtml", model]); }; Post["/band/{id}/add-venue"] = parameters => { Band currentBand = Band.Find(parameters.id); Venue currentVenue = Venue.Find(Request.Form["venueId"]); currentBand.AddVenue(Request.Form["venueId"]); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("band", currentBand); model.Add("venue", currentVenue); return(View["saved.cshtml", model]); }; Get["/venue/{id}"] = parameters => { Venue currentVenue = Venue.Find(parameters.id); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("venue", currentVenue); model.Add("venueBands", currentVenue.GetBands()); model.Add("bands", Band.GetAll()); return(View["venue.cshtml", model]); }; Post["/venue/{id}/add-band"] = parameters => { Venue currentVenue = Venue.Find(parameters.id); Band currentBand = Band.Find(Request.Form["bandId"]); currentVenue.AddBand(Request.Form["bandId"]); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("band", currentBand); model.Add("venue", currentVenue); return(View["saved.cshtml", model]); }; Get["/band/{id}/edit"] = parameters => { Band currentBand = Band.Find(parameters.id); return(View["edit-band-form.cshtml", currentBand]); }; Get["/venue/{id}/edit"] = parameters => { Venue currentVenue = Venue.Find(parameters.id); return(View["edit-venue-form.cshtml", currentVenue]); }; Patch["/band/{id}"] = parameters => { Band currentBand = Band.Find(parameters.id); currentBand.Edit(Request.Form["newName"]); return(View["edit-success.cshtml", currentBand]); }; Patch["/venue/{id}"] = parameters => { Venue currentVenue = Venue.Find(parameters.id); currentVenue.Edit(Request.Form["newName"]); return(View["edit-success.cshtml", currentVenue]); }; Delete["/band/{id}"] = parameters => { Band currentBand = Band.Find(parameters.id); currentBand.Delete(); return(View["delete-success.cshtml", currentBand]); }; Delete["/venue/{id}"] = parameters => { Venue currentVenue = Venue.Find(parameters.id); currentVenue.Delete(); return(View["delete-success.cshtml", currentVenue]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/bands"] = _ => { List <Band> allBands = Band.GetAll(); return(View["bands.cshtml", allBands]); }; Get["/venues"] = _ => { List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Post["/bands"] = _ => { List <Band> allBands = Band.GetAll(); return(View["bands.cshtml", allBands]); }; Post["/venues"] = _ => { List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Get["/band/{id}"] = parameters => { Band newBand = Band.Find(parameters.id); List <Venue> allVenues = Venue.GetAll(); List <Venue> bandVenue = newBand.GetVenues(); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("band", newBand); model.Add("allVenues", allVenues); model.Add("bandVenue", bandVenue); return(View["band.cshtml", model]); }; Get["/venue/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Venue newVenue = Venue.Find(parameters.id); List <Band> allBands = Band.GetAll(); List <Band> venueBands = newVenue.GetBands(); model.Add("venue", newVenue); model.Add("allBands", allBands); model.Add("venueBands", venueBands); return(View["venue.cshtml", model]); }; Post["/bands/new"] = _ => { Band newBand = new Band(Request.Form["band-name"]); newBand.Save(); List <Band> allBands = Band.GetAll(); return(View["bands.cshtml", allBands]); }; Post["/venues/new"] = _ => { Venue newVenue = new Venue(Request.Form["venue-name"]); newVenue.Save(); List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Get["/venue/delete/{id}"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Delete["/venue/delete/{id}"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.DeleteVenue(); List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Get["/venue/update/{id}"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); return(View["edit_venue.cshtml", selectedVenue]); }; Post["/venue/update/{id}"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); return(View["edit_venue.cshtml", selectedVenue]); }; Patch["/venue/update/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.UpdateVenue(Request.Form["new-venue-name"]); List <Band> allBands = Band.GetAll(); List <Band> venueBands = selectedVenue.GetBands(); model.Add("venue", selectedVenue); model.Add("allBands", allBands); model.Add("venueBands", venueBands); return(View["venue.cshtml", model]); }; Post["/venue/add_band/{id}"] = parameters => { Band band = Band.Find(Request.Form["band-id"]); Venue venue = Venue.Find(Request.Form["venue-id"]); venue.AddBand(band); Dictionary <string, object> model = new Dictionary <string, object>(); List <Band> allBands = Band.GetAll(); List <Band> venueBands = venue.GetBands(); model.Add("venue", venue); model.Add("band", band); model.Add("allBands", allBands); model.Add("venueBands", venueBands); return(View["venue.cshtml", model]); }; Post["/band/add_venue/{id}"] = parameters => { Band band = Band.Find(Request.Form["band-id"]); Venue venue = Venue.Find(Request.Form["venue-id"]); band.AddVenue(venue); List <Venue> allVenues = Venue.GetAll(); List <Venue> bandVenue = band.GetVenues(); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("band", band); model.Add("allVenues", allVenues); model.Add("bandVenue", bandVenue); return(View["band.cshtml", model]); }; }
public void Test_AddBand_AddsBandToVenue() { //Arrange Venue testVenue = new Venue("A"); testVenue.Save(); DateTime testTime = new DateTime(2016, 1, 1); Band testBand = new Band("A",testTime); testBand.Save(); Band testBand2 = new Band("B",testTime); testBand2.Save(); //Act testVenue.AddBand(testBand); testVenue.AddBand(testBand2); List<Band> result = testVenue.GetBands(); List<Band> testList = new List<Band> {testBand, testBand2}; Assert.Equal(testList, result); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/bands"] = _ => { List <Band> allBands = Band.GetAll(); return(View["bands.cshtml", allBands]); }; Get["/bands/new"] = _ => { return(View["bands_form.cshtml"]); }; Post["/bands/new"] = _ => { Band newBand = new Band(Request.Form["band-name"]); newBand.Save(); return(View["success.cshtml"]); }; Get["/bands/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Band selectedBand = Band.Find(parameters.id);//gets current band info 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]); }; Post["band/add_venue"] = _ => { Band newBand = Band.Find(Request.Form["band-id"]); Venue newVenue = Venue.Find(Request.Form["venue-id"]); newBand.AddVenue(newVenue); return(View["success.cshtml"]); }; Get["/venues"] = _ => { List <Venue> allVenues = Venue.GetAll(); return(View["venues.cshtml", allVenues]); }; Get["/venues/new"] = _ => { return(View["venues_form.cshtml"]); }; Post["/venues/new"] = _ => { Venue newVenue = new Venue(Request.Form["venue-name"]); newVenue.Save(); return(View["success.cshtml"]); }; 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]); }; Post["venue/add_band"] = _ => { Venue newVenue = Venue.Find(Request.Form["venue-id"]); Band newBand = Band.Find(Request.Form["band-id"]); newVenue.AddBand(newBand); return(View["success.cshtml"]); }; Get["/venue/{id}/update"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); return(View["venue_update.cshtml", selectedVenue]); }; Patch["/venue/{id}/update"] = parameters => { Venue foundVenue = Venue.Find(parameters.id); foundVenue.Update(Request.Form["update-location"]); return(View["success.cshtml"]); }; Delete["/venue/{id}/delete"] = parameters => { Venue foundVenue = Venue.Find(parameters.id); foundVenue.Delete(); return(View["success.cshtml"]); }; Post["/bands/delete"] = _ => { Band.DeleteAll(); return(View["success.cshtml"]); }; Post["/venues/delete"] = _ => { Venue.DeleteAll(); return(View["success.cshtml"]); }; }
public void Test_GetBands_ReturnAllVenueBands() { Venue testVenue = new Venue("place"); testVenue.Save(); DateTime testTime = new DateTime(2016, 1, 1); Band testBand1= new Band("A",testTime); testBand1.Save(); Band testBand2 = new Band("C",testTime); testBand2.Save(); testVenue.AddBand(testBand1); List<Band> savedBands = testVenue.GetBands(); List<Band> testList= new List<Band>{testBand1}; Assert.Equal(testList,savedBands); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/bands"] = _ => { List <Band> AllBands = Band.GetAll(); return(View["bands.cshtml", AllBands]); }; Get["/venues"] = _ => { List <Venue> AllVenues = Venue.GetAll(); return(View["venues.cshtml", AllVenues]); }; //Create a new band. Get["/bands/new"] = _ => { return(View["bands_form.cshtml"]); }; Post["/bands/new"] = _ => { Band newBand = new Band(Request.Form["band-name"]); newBand.Save(); return(View["success.cshtml"]); }; //Create a new venue. Get["/venues/new"] = _ => { return(View["venues_form.cshtml"]); }; Post["/venues/new"] = _ => { Venue newVenue = new Venue(Request.Form["venue-name"]); newVenue.Save(); return(View["success.cshtml"]); }; Get["venues/{id}"] = param => { Dictionary <string, object> model = new Dictionary <string, object>(); Venue SelectedVenue = Venue.Find(param.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]); }; Get["bands/{id}"] = param => { Dictionary <string, object> model = new Dictionary <string, object>(); Band SelectedBand = Band.Find(param.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]); }; Post["band/add_venue"] = _ => { Venue venue = Venue.Find(Request.Form["venue-id"]); Band band = Band.Find(Request.Form["band-id"]); band.AddVenue(venue); return(View["success.cshtml"]); }; Post["venue/add_band"] = _ => { Venue venue = Venue.Find(Request.Form["venue-id"]); Band band = Band.Find(Request.Form["band-id"]); venue.AddBand(band); return(View["success.cshtml"]); }; Get["venues/delete/{id}"] = param => { Venue SelectedVenue = Venue.Find(param.id); return(View["venues_delete.cshtml", SelectedVenue]); }; Delete["venues/delete/{id}"] = param => { Venue SelectedVenue = Venue.Find(param.id); SelectedVenue.Delete(); return(View["success.cshtml"]); }; Get["/venues/edit/{id}"] = param => { Venue SelectedVenue = Venue.Find(param.id); return(View["venues_edit.cshtml", SelectedVenue]); }; Post["/venues/edit/{id}"] = param => { Venue SelectedVenue = Venue.Find(param.id); return(View["success.cshtml", SelectedVenue]); }; Patch["/venues/edit/{id}"] = param => { Venue SelectedVenue = Venue.Find(param.id); SelectedVenue.Update(Request.Form["edit-venue-name"]); return(View["success.cshtml"]); }; }
public void Test_GetBands_ReturnsAllVenueBands() { //Arrange Venue testVenue = new Venue("The Catwalk"); testVenue.Save(); Band testBand1 = new Band("The LoudMouths"); testBand1.Save(); Band testBand2 = new Band("The NoiseMakers"); testBand2.Save(); List<Band> testList = new List<Band> {testBand1}; //Act testVenue.AddBand(testBand1); List<Band> savedBands = testVenue.GetBands(); //Assert Assert.Equal(testList, savedBands); }
public void Test_Delete_DeletesBandAssociationsFromDatabase() { //Arrange Venue testVenue = new Venue("Hello"); testVenue.Save(); DateTime testTime = new DateTime(2016, 1, 1); string testName = "A"; Band testBand = new Band(testName,testTime); testBand.Save(); //Act testBand.AddVenue(testVenue); testBand.Delete(); List<Band> resultVenueBands = testVenue.GetBands(); List<Band> testVenueBands = new List<Band> {}; //Assert Assert.Equal(testVenueBands, resultVenueBands); }