public void Test_Save_Find_Delete()
 {
     Band testBand = new Band("Pazz", "Jeff and the Baboons");
       testBand.Save();
       testBand.Delete(new string[] {"performances"}, new string[] {"band_id"});
       Assert.Equal(null, Band.Find(testBand.id));
 }
Example #2
0
        public void Delete_RemoveBandFromDatabase_Deleted()
        {
            Band newBand = new Band("Adele");

            newBand.Save();

            Band.Delete(newBand.GetId());

            Assert.Equal(0, Band.GetAll().Count);
        }
Example #3
0
        public void Test_Delete_DeletesBandFromDatabase()
        {
            //Arrange
            Band testBand = new Band("Angry Fish");

            testBand.Save();

            //Act
            testBand.Delete();
            List <Band> result    = Band.GetBands();
            List <Band> testBands = new List <Band> {
            };

            //Assert
            Assert.Equal(testBands, result);
        }
Example #4
0
        public void Delete_OneBand_BandDeleted()
        {
            Band testBand1 = new Band("band1");

            testBand1.Save();
            Band testBand2 = new Band("band2");

            testBand2.Save();

            testBand1.Delete();

            List <Band> allBands = Band.GetAll();
            List <Band> expected = new List <Band> {
                testBand2
            };

            Assert.Equal(expected, allBands);
        }
        public void Delete_DeletesBandFromDB_true()
        {
            //Arrange
            Band newBand1 = new Band("KISS");
            Band newBand2 = new Band("Metallica");

            newBand1.Save();
            newBand2.Save();
            //Act
            newBand1.Delete();
            List <Band> result         = Band.GetAll();
            List <Band> expectedResult = new List <Band> {
                newBand2
            };

            //Assert
            Assert.Equal(expectedResult, result);
        }
        public void Test_Delete_DeleteSingleBandFromDatabase()
        {
            //Arrange
            Band testBand1 = new Band("ColdPlay");

            testBand1.Save();
            Band testBand2 = new Band("ColdPlay");

            testBand2.Save();

            //Act
            testBand1.Delete();
            List <Band> result     = Band.GetAll();
            List <Band> resultList = new List <Band> {
                testBand2
            };

            Assert.Equal(result, resultList);
        }
Example #7
0
        public void Test8_DeleteOneFromDatabase()
        {
            Venue testVenue = new Venue("Skydome");

            testVenue.Save();

            Band testBand = new Band("Ac/dc");

            testBand.Save();

            testBand.AddVenue(testVenue);
            testBand.Delete();

            List <Band> resultVenueBands = testVenue.GetBands();
            List <Band> testVenueBands   = new List <Band> {
            };

            Assert.Equal(testVenueBands, resultVenueBands);
        }
Example #8
0
        [Fact]//DELETE
        public void Delete_DeletesTargetBand_ListLength1()
        {
            //Arrange
            Band testBand1 = new Band("The Chameleons", 4);

            testBand1.Save();
            Band testBand2 = new Band("The Olllam", 4);

            testBand2.Save();
            List <Band> expectedList = new List <Band> {
                testBand2
            };

            //Act
            Band.Delete(testBand1.Id);
            List <Band> resultList = Band.GetAll();

            //Assert
            Assert.Equal(expectedList, resultList);
        }
Example #9
0
        public void Delete_DeleteBandAssociationsFromDataBase_ListOfBands()
        {
            //Arrange
            Venue testVenue = new Venue("Red Rocks, Morrison, CO");

            testVenue.Save();

            Band testBand = new Band("Little Hurricane");

            testBand.Save();

            //Act
            testBand.AddVenue(testVenue);
            testBand.Delete();

            List <Band> venueBands     = testVenue.GetBands();
            List <Band> testVenueBands = new List <Band> {
            };

            //Assert
            Assert.Equal(testVenueBands, venueBands);
        }
Example #10
0
        public void Delete_DeletesBandAssociationsFromDatabase_BandList()
        {
            //Arrange
            Band testBand = new Band("reo", "rock");

            testBand.Save();

            Venue testVenue = new Venue("Moda", "mars", 10000);

            testVenue.Save();

            //Act
            testBand.AddVenue(testVenue);
            testBand.Delete();

            List <Band> resultVenueBand = testVenue.GetBand();
            List <Band> testVenueBand   = new List <Band> {
            };

            //Assert
            Assert.Equal(testVenueBand, resultVenueBand);
        }
Example #11
0
        public void Test_Delete_DeletesBandFromVenue()
        {
            //Arrange
            Venue testVenue = new Venue("White River Ampitheater");

            testVenue.Save();

            Band testBand = new Band("Nirvana");

            testBand.Save();

            //Act
            testBand.AddVenue(testVenue);
            testBand.Delete();

            List <Band> resultVenueBands = testVenue.GetBands();
            List <Band> testVenueBands   = new List <Band> {
            };

            //Assert
            Assert.Equal(testVenueBands, resultVenueBands);
        }
Example #12
0
        public void Test_Delete_DeletesBandAssociationsFromDatabase()
        {
            //Arrange
            Venue testVenue = new Venue("Meany Hall");

            testVenue.Save();

            Band testBand = new Band("Pentatonix", "Pop", "Problem");

            testBand.Save();

            //Act
            testBand.AddVenue(testVenue);
            testBand.Delete();

            List <Band> resultVenuesBands = testVenue.GetBands();
            List <Band> testVenuesBands   = new List <Band> {
            };

            //Assert
            Assert.Equal(testVenuesBands, resultVenuesBands);
        }
Example #13
0
        public void Test_Delete_DeletesBandFromDatabase()
        {
            //Arrange
            string name1     = "Name";
            Band   testBand1 = new Band(name1);

            testBand1.Save();

            string name2     = "Other name";
            Band   testBand2 = new Band(name2);

            testBand2.Save();

            //Act
            testBand1.Delete();
            List <Band> resultBands  = Band.GetAll();
            List <Band> testBandList = new List <Band> {
                testBand2
            };

            //Assert
            Assert.Equal(testBandList, resultBands);
        }
Example #14
0
        public void Test_Delete_DeletesBandAssociationsFromDatabase()
        {
            //Arrange
            Venue testVenue = new Venue("Object name");

            testVenue.Save();

            string testName = "Name";
            Band   testBand = new Band(testName);

            testBand.Save();

            //Act
            testBand.AddVenue(testVenue);
            testBand.Delete();

            List <Band> resultVenueBands = testVenue.GetBands();
            List <Band> testVenueBands   = new List <Band> {
            };

            //Assert
            Assert.Equal(testVenueBands, resultVenueBands);
        }
Example #15
0
        public void Test_Delete_DeletesBandFromDatabase()
        {
            Band band1 = new Band("Some Band Name", "Some Band Description");

            band1.Save();

            Band band2 = new Band("Some Band Name", "Some Band Description");

            band2.Save();

            Band band3 = new Band("Some Band Name", "Some Band Description");

            band3.Save();

            band2.Delete();

            List <Band> expected = Band.GetAll();
            List <Band> result   = new List <Band> {
                band1, band3
            };

            Assert.Equal(expected, result);
        }
Example #16
0
        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["/bands/new"] = _ => {
                List <Venue> AllVenues = Venue.GetAll();
                return(View["bands_form.cshtml", AllVenues]);
            };
            Post["/bands"] = _ => {
                Band newBand = new Band(Request.Form["band-name"]);
                newBand.Save();
                newBand.AddVenue(Venue.Find(Request.Form["venue-id"]));
                List <Band> AllBands = Band.GetAll();
                return(View["bands.cshtml", AllBands]);
            };
            Get["/venues/new"] = _ => {
                List <Band> AllBands = Band.GetAll();
                return(View["venues_form.cshtml", AllBands]);
            };
            Post["/venues"] = _ => {
                Venue newVenue = new Venue(Request.Form["venue-name"]);
                newVenue.Save();
                newVenue.AddBand(Band.Find(Request.Form["band-id"]));
                List <Venue> AllVenues = Venue.GetAll();
                return(View["venues.cshtml", AllVenues]);
            };

            Get["/bands/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var SelectedBand = Band.Find(parameters.id);
                var VenueBand    = SelectedBand.GetVenues();
                model.Add("bands", SelectedBand);
                model.Add("venues", VenueBand);
                return(View["band.cshtml", model]);
            };

            Get["/venues/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var SelectedVenue = Venue.Find(parameters.id);
                var VenueBand     = SelectedVenue.GetBands();
                model.Add("venues", SelectedVenue);
                model.Add("bands", VenueBand);
                return(View["venue.cshtml", model]);
            };

            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"]);
                List <Venue> AllVenues = Venue.GetAll();
                return(View["venues.cshtml", AllVenues]);
            };

            Post["/venues/delete"] = _ => {
                Venue.DeleteAll();
                List <Venue> AllVenues = Venue.GetAll();
                return(View["venues.cshtml", AllVenues]);
            };
            Post["/bands/delete"] = _ => {
                Band.DeleteAll();
                List <Band> AllBands = Band.GetAll();
                return(View["bands.cshtml", AllBands]);
            };
            Get["venue/delete/{id}"] = parameters => {
                Venue SelectedVenue = Venue.Find(parameters.id);
                return(View["venue_delete.cshtml", SelectedVenue]);
            };
            Delete["venue/delete/{id}"] = parameters => {
                Venue SelectedVenue = Venue.Find(parameters.id);
                SelectedVenue.Delete();
                List <Venue> AllVenues = Venue.GetAll();
                return(View["venues.cshtml", AllVenues]);
            };
            Get["band/delete/{id}"] = parameters => {
                Band SelectedBand = Band.Find(parameters.id);
                return(View["band_delete.cshtml", SelectedBand]);
            };
            Delete["band/delete/{id}"] = parameters => {
                Band SelectedBand = Band.Find(parameters.id);
                SelectedBand.Delete();
                List <Band> AllBands = Band.GetAll();
                return(View["bands.cshtml", AllBands]);
            };
        }
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/add/band"] = _ => {
         List <Band> allBands = Band.GetAll();
         return(View["band_form.cshtml", allBands]);
     };
     Post["/add/band"] = _ => {
         Band newBand = new Band(Request.Form["band-name"], Request.Form["contact"]);
         newBand.Save();
         return(View["bands.cshtml", Band.GetAll()]);
     };
     Get["/band/{id}"] = parameters => {
         Dictionary <string, object> bandDict = new Dictionary <string, object>();
         var currentBand = Band.Find(parameters.id);
         bandDict.Add("band", currentBand);
         List <Venue> allVenues = Venue.GetAll();
         bandDict.Add("venues", allVenues);
         List <Venue> bandVenues = currentBand.GetVenues();
         bandDict.Add("venuesPlayed", bandVenues);
         return(View["band.cshtml", bandDict]);
     };
     Get["/add/band/{id}/venue"] = parameters => {
         Band         currentBand = Band.Find(parameters.id);
         List <Venue> allVenues   = Venue.GetAll();
         Dictionary <string, object> bandVenues = new Dictionary <string, object>();
         bandVenues.Add("band", currentBand);
         bandVenues.Add("venues", allVenues);
         return(View["add_venue_to_band.cshtml", bandVenues]);
     };
     Post["/add/band/{id}/venue"] = parameters => {
         Dictionary <string, object> bandDict = new Dictionary <string, object>();
         Band  currentBand    = Band.Find(parameters.id);
         int   venueMenueItem = int.Parse(Request.Form["venue_id"]);
         Venue currentVenue   = Venue.Find(venueMenueItem);
         currentBand.AddVenue(currentVenue);
         bandDict.Add("band", currentBand);
         List <Venue> allVenues = Venue.GetAll();
         bandDict.Add("venues", allVenues);
         List <Venue> bandVenues = currentBand.GetVenues();
         bandDict.Add("venuesPlayed", bandVenues);
         return(View["band.cshtml", bandDict]);
     };
     Delete["/band/{id}/delete"] = parameters => {
         Band currentBand = Band.Find(parameters.id);
         currentBand.Delete();
         return(View["band_form.cshtml", Band.GetAll()]);
     };
     Get["/add/venue"] = _ => {
         List <Venue> allVenues = Venue.GetAll();
         return(View["venue_form.cshtml", allVenues]);
     };
     Post["/add/venue"] = _ => {
         Venue newVenue = new Venue(Request.Form["venue-name"], Request.Form["contact"]);
         newVenue.Save();
         return(View["venues.cshtml", Venue.GetAll()]);
     };
     Get["/venue/{id}"] = parameters => {
         Dictionary <string, object> VenueDict = new Dictionary <string, object>();
         var currentVenue = Venue.Find(parameters.id);
         VenueDict.Add("Venue", currentVenue);
         List <Band> allBands = Band.GetAll();
         VenueDict.Add("bands", allBands);
         List <Band> bandVenues = currentVenue.GetBands();
         VenueDict.Add("bandsPlayed", bandVenues);
         return(View["venue.cshtml", VenueDict]);
     };
     Get["/add/venue/{id}/band"] = parameters => {
         Venue       currentVenue = Venue.Find(parameters.id);
         List <Band> allBands     = Band.GetAll();
         Dictionary <string, object> bandVenues = new Dictionary <string, object>();
         bandVenues.Add("band", allBands);
         bandVenues.Add("Venue", currentVenue);
         return(View["add_band_to_venue.cshtml", bandVenues]);
     };
     Post["/add/venue/{id}/band"] = parameters => {
         Dictionary <string, object> venueDict = new Dictionary <string, object>();
         Venue currentVenue  = Venue.Find(parameters.id);
         int   bandMenueItem = int.Parse(Request.Form["band_id"]);
         Band  currentBand   = Band.Find(bandMenueItem);
         currentVenue.AddBand(currentBand);
         venueDict.Add("Venue", currentVenue);
         List <Band> allBands = Band.GetAll();
         venueDict.Add("bands", allBands);
         List <Band> bandVenues = currentVenue.GetBands();
         venueDict.Add("bandsPlayed", bandVenues);
         return(View["venue.cshtml", venueDict]);
     };
     Get["/edit/venue/{id}"] = parameters => {
         Venue currentVenue = Venue.Find(parameters.id);
         return(View["edit_venue_form.cshtml", currentVenue]);
     };
     Patch["edit/venue/{id}"] = parameters => {
         Dictionary <string, object> VenueDict = new Dictionary <string, object>();
         Venue currentVenue = Venue.Find(parameters.id);
         currentVenue.Edit(Request.Form["venue-name"], Request.Form["contact"]);
         VenueDict.Add("Venue", currentVenue);
         List <Band> allBands = Band.GetAll();
         VenueDict.Add("bands", allBands);
         List <Band> bandVenues = currentVenue.GetBands();
         VenueDict.Add("bandsPlayed", bandVenues);
         return(View["venue.cshtml", VenueDict]);
     };
     Delete["/venue/{id}/delete"] = parameters => {
         Venue currentVenue = Venue.Find(parameters.id);
         currentVenue.Delete();
         return(View["venue_form.cshtml", Venue.GetAll()]);
     };
 }
Example #18
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Band> allBands = Band.GetAll();
                return(View["index.cshtml", allBands]);
            };

            Get["/venues"] = _ => {
                List <Venue> allVenues = Venue.GetAll();
                return(View["venues.cshtml", allVenues]);
            };

            Get["/venues/new"] = _ => {
                return(View["venue_form.cshtml"]);
            };

            Post["/venues/new"] = _ => {
                string venueName     = Request.Form["venue-name"];
                string venueLocation = Request.Form["venue-location"];

                Venue newVenue = new Venue(venueName, venueLocation);
                newVenue.Save();
                return(View["venue_added.cshtml", newVenue]);
            };

            Get["/bands/new"] = _ => {
                return(View["band_form.cshtml"]);
            };

            Post["/bands/new"] = _ => {
                string bandName        = Request.Form["band-name"];
                string bandDescription = Request.Form["band-description"];

                Band newBand = new Band(bandName, bandDescription);
                newBand.Save();
                return(View["band_added.cshtml", newBand]);
            };

            Get["/venue/{id}"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                return(View["venue.cshtml", selectedVenue]);
            };

            Get["/band/{id}"] = parameters => {
                Band selectedBand = Band.Find(parameters.id);
                return(View["band.cshtml", selectedBand]);
            };

            Get["/venue/{id}/new_band"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                return(View["venue_add_band.cshtml", selectedVenue]);
            };

            Post["/venue/{id}/new_band"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                int   bandId        = int.Parse(Request.Form["band-id"]);

                Band selectedBand = Band.Find(bandId);
                selectedVenue.AddBand(selectedBand);
                return(View["venue.cshtml", selectedVenue]);
            };

            Get["/band/{id}/new_venue"] = parameters => {
                Band selectedBand = Band.Find(parameters.id);
                return(View["band_add_venue.cshtml", selectedBand]);
            };

            Post["/band/{id}/new_venue"] = parameters => {
                Band selectedBand = Band.Find(parameters.id);
                int  venueId      = int.Parse(Request.Form["venue-id"]);

                Venue selectedVenue = Venue.Find(venueId);
                selectedBand.AddVenue(selectedVenue);
                return(View["band.cshtml", selectedBand]);
            };

            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);

                string venueName     = Request.Form["venue-name"];
                string venueLocation = Request.Form["venue-location"];

                selectedVenue.Update(venueName, venueLocation);
                Venue updatedVenue = Venue.Find(parameters.id);
                return(View["venue_edited.cshtml", updatedVenue]);
            };

            Get["/band/edit/{id}"] = parameters => {
                Band selectedBand = Band.Find(parameters.id);
                return(View["band_edit.cshtml", selectedBand]);
            };

            Patch["/band/edit/{id}"] = parameters => {
                Band selectedBand = Band.Find(parameters.id);

                string bandName        = Request.Form["band-name"];
                string bandDescription = Request.Form["band-description"];

                selectedBand.Update(bandName, bandDescription);
                Band updatedBand = Band.Find(parameters.id);
                return(View["band_edited.cshtml", updatedBand]);
            };

            Get["/venue/delete/{id}"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                return(View["venue_delete.cshtml", selectedVenue]);
            };

            Delete["/venue/delete/{id}"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                selectedVenue.Delete();
                return(View["entry_deleted.cshtml"]);
            };

            Get["/band/delete/{id}"] = parameters => {
                Band selectedBand = Band.Find(parameters.id);
                return(View["band_delete.cshtml", selectedBand]);
            };

            Delete["/band/delete/{id}"] = parameters => {
                Band selectedBand = Band.Find(parameters.id);
                selectedBand.Delete();
                return(View["entry_deleted.cshtml"]);
            };

            Delete["/band/remove_venue/{id}"] = parameters => {
                int   bandId        = int.Parse(Request.Form["band-id"]);
                Band  selectedBand  = Band.Find(bandId);
                Venue selectedVenue = Venue.Find(parameters.id);

                selectedBand.RemoveVenue(selectedVenue);
                return(View["band.cshtml", selectedBand]);
            };

            Delete["/venue/remove_band/{id}"] = parameters => {
                int   venueId       = int.Parse(Request.Form["venue-id"]);
                Venue selectedVenue = Venue.Find(venueId);
                Band  selectedBand  = Band.Find(parameters.id);

                selectedVenue.RemoveBand(selectedBand);
                return(View["venue.cshtml", selectedVenue]);
            };
        }
Example #19
0
        public HomeModule()
        {
            Get["/"] = _ => View["index.cshtml"];

////BANDS////
            Get["/bands"] = _ => {
                List <Band> allBands = Band.GetAll();
                return(View["all_bands.cshtml", allBands]);
            };

            Get["/bands/new"] = _ => View["new_band_form.cshtml"];

            Post["/bands/new"] = _ => {
                string newBandName    = Request.Form["band-name"];
                int    newBandMembers = int.Parse(Request.Form["number-members"]);
                Band   newBand        = new Band(newBandName, newBandMembers);
                newBand.Save();
                return(View["band.cshtml", newBand]);
            };

            Get["/bands/{id}"] = parameters => {
                Band foundBand = Band.Find(parameters.id);
                return(View["band.cshtml", foundBand]);
            };

            Get["/bands/{id}/update"] = parameters => {
                Band foundBand = Band.Find(parameters.id);
                return(View["band_update.cshtml", foundBand]);
            };

            Patch["/bands/update"] = parameters => {
                string newBandName    = Request.Form["band-name"];
                int    newBandMembers = int.Parse(Request.Form["number-members"]);
                int    targetId       = int.Parse(Request.Form["target-id"]);
                Band.Update(targetId, newBandName, newBandMembers);
                Band foundBand = Band.Find(targetId);
                return(View["band.cshtml", foundBand]);
            };

            Delete["/bands/delete"] = _ => {
                int targetId = int.Parse(Request.Form["target-id"]);
                Band.Delete(targetId);
                List <Band> allBands = Band.GetAll();
                return(View["all_bands.cshtml", allBands]);
            };

            Delete["/bands/delete_all"] = _ => {
                Band.DeleteAll();
                List <Band> allBands = Band.GetAll();
                return(View["all_bands.cshtml", allBands]);
            };


////VENUES////
            Get["/venues"] = _ => {
                List <Venue> allVenues = Venue.GetAll();
                return(View["all_venues.cshtml", allVenues]);
            };

            Get["/venues/new"] = _ => View["new_venue_form.cshtml"];

            Post["/venues/new"] = _ => {
                string newVenueName     = Request.Form["venue-name"];
                string newVenueSize     = Request.Form["venue-size"];
                int    newVenueCapacity = int.Parse(Request.Form["venue-capacity"]);
                Venue  newVenue         = new Venue(newVenueName, newVenueSize, newVenueCapacity);
                newVenue.Save();
                return(View["venue.cshtml", newVenue]);
            };

            Get["/venues/{id}"] = parameters => {
                Venue foundVenue = Venue.Find(parameters.id);
                return(View["venue.cshtml", foundVenue]);
            };

            Get["/venues/{id}/update"] = parameters => {
                Venue foundVenue = Venue.Find(parameters.id);
                return(View["venue_update.cshtml", foundVenue]);
            };

            Patch["/venues/update"] = parameters => {
                string newVenueName     = Request.Form["venue-name"];
                string newVenueSize     = Request.Form["venue-size"];
                int    newVenueCapacity = int.Parse(Request.Form["venue-capacity"]);
                int    targetId         = int.Parse(Request.Form["target-id"]);
                Venue.Update(targetId, newVenueName, newVenueSize, newVenueCapacity);
                Venue foundVenue = Venue.Find(targetId);
                return(View["venue_update.cshtml", foundVenue]);
            };

            Delete["/venues/delete"] = _ => {
                int targetId = int.Parse(Request.Form["target-id"]);
                Venue.Delete(targetId);
                List <Venue> allVenues = Venue.GetAll();
                return(View["all_venues.cshtml", allVenues]);
            };

            Delete["/venues/delete_all"] = _ => {
                Venue.DeleteAll();
                List <Venue> allVenues = Venue.GetAll();
                return(View["all_venues.cshtml", allVenues]);
            };

////GENRES////
            Get["/genres"] = _ => {
                List <Genre> allGenres = Genre.GetAll();
                return(View["all_genres.cshtml", allGenres]);
            };

            Get["/genres/new"] = _ => View["new_genre_form.cshtml"];

            Post["/genres/new"] = _ => {
                string newGenreName = Request.Form["genre-name"];
                Genre  newGenre     = new Genre(newGenreName);
                newGenre.Save();
                return(View["genre.cshtml", newGenre]);
            };

            Get["/genres/{id}"] = parameters => {
                Genre foundGenre = Genre.Find(parameters.id);
                return(View["genre.cshtml", foundGenre]);
            };

            Delete["/genres/delete"] = _ => {
                int targetId = int.Parse(Request.Form["target-id"]);
                Genre.Delete(targetId);
                List <Genre> allGenres = Genre.GetAll();
                return(View["all_genres.cshtml", allGenres]);
            };

            Delete["/genres/delete_all"] = _ => {
                Genre.DeleteAll();
                List <Genre> allGenres = Genre.GetAll();
                return(View["all_genres.cshtml", allGenres]);
            };

            Get["/genres/{id}/update"] = parameters => {
                Genre foundGenre = Genre.Find(parameters.id);
                return(View["genre_update.cshtml", foundGenre]);
            };

            Patch["/genres/update"] = parameters => {
                string newGenreName = Request.Form["genre-name"];
                int    targetId     = int.Parse(Request.Form["target-id"]);
                Genre.Update(targetId, newGenreName);
                Genre foundGenre = Genre.Find(targetId);
                return(View["genre_update.cshtml", foundGenre]);
            };

            Get["/venue-genre"] = _ => {
                List <Venue> allVenues = Venue.GetAll();
                List <Genre> allGenres = Genre.GetAll();

                Dictionary <string, object> returnModel = new Dictionary <string, object>()
                {
                    { "venues", allVenues },
                    { "genres", allGenres }
                };

                return(View["venue_genre.cshtml", returnModel]);
            };

            Post["/venue-genre"] = _ => {
                int venueId = int.Parse(Request.Form["venue"]);
                int genreId = int.Parse(Request.Form["genre"]);

                Venue foundVenue = Venue.Find(venueId);
                foundVenue.AddGenre(genreId);
                return(View["venue.cshtml", foundVenue]);
            };

            Get["/band-genre"] = _ => {
                List <Band>  allBands  = Band.GetAll();
                List <Genre> allGenres = Genre.GetAll();

                Dictionary <string, object> returnModel = new Dictionary <string, object>()
                {
                    { "bands", allBands },
                    { "genres", allGenres }
                };

                return(View["band_genre.cshtml", returnModel]);
            };

            Post["/band-genre"] = _ => {
                int bandId  = int.Parse(Request.Form["band"]);
                int genreId = int.Parse(Request.Form["genre"]);

                Band foundBand = Band.Find(bandId);
                foundBand.AddGenre(genreId);
                return(View["band.cshtml", foundBand]);
            };

// Performances
            Get["/performance"] = _ => {
                List <Band>  allBands  = Band.GetAll();
                List <Venue> allVenues = Venue.GetAll();

                Dictionary <string, object> returnModel = new Dictionary <string, object>()
                {
                    { "bands", allBands },
                    { "venues", allVenues }
                };
                return(View["performance.cshtml", returnModel]);
            };

            Post["/performance"] = _ => {
                int  venueId   = int.Parse(Request.Form["venue"]);
                int  bandId    = int.Parse(Request.Form["band"]);
                Band foundBand = Band.Find(bandId);
                foundBand.AddPerformance(venueId);
                return(View["band.cshtml", foundBand]);
            };
        }
 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]);
     };
 }
Example #21
0
        public HomeModule()
        {
            // Take you to the homepage
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };

            // Take you to the venues page
            Get["/venues"] = _ => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                List <Venue> allVenues            = Venue.GetAllVenues();
                model.Add("venue", allVenues);
                return(View["venues.cshtml", model]);
            };
            // Post for adding a new venue
            Post["/venues"] = _ => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Venue newVenue = new Venue(Request.Form["venue"]);
                newVenue.Save();
                List <Venue> allVenues = Venue.GetAllVenues();
                model.Add("venue", allVenues);
                return(View["venues.cshtml", model]);
            };
            // Take you to an individual venue page
            Get["/venues/{id}/{name}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Venue       selectedVenue         = Venue.Find(parameters.id);
                List <Band> allBands = Band.GetAllBands();
                model.Add("venue", selectedVenue);
                model.Add("bands", allBands);
                return(View["venue.cshtml", model]);
            };
            // Post a new band to a venue
            Post["/venues/{id}/{name}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Band  newBand      = new Band(Request.Form["add-band"]);
                Venue currentVenue = Venue.Find(Request.Form["venue-id"]);
                newBand.Save();
                List <Venue> allVenues = Venue.GetAllVenues();
                currentVenue.AddBand(newBand);
                List <Band> allBands = Band.GetAllBands();
                model.Add("venue", currentVenue);
                model.Add("bands", allBands);
                return(View["venue.cshtml", model]);
            };

            // Take you to the bands page
            Get["/bands"] = _ => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                List <Band> allBands = Band.GetAllBands();
                model.Add("bands", allBands);
                return(View["bands.cshtml", model]);
            };
            // Take you to an individual band page
            Get["/bands/{id}/{name}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Band         selectedBand         = Band.Find(parameters.id);
                List <Venue> allVenues            = Venue.GetAllVenues();
                model.Add("band", selectedBand);
                model.Add("venues", allVenues);
                return(View["band.cshtml", model]);
            };

            // Take you to the page to edit a venue
            Get["/venues/{id}/{name}/edit"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                return(View["edit_venue.cshtml", selectedVenue]);
            };

            // Edit a venue
            Patch["/venue/{id}/updated"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                selectedVenue.Update(Request.Form["edit-venue"]);
                return(View["venue_updated.cshtml", selectedVenue]);
            };

            // take you to page to delete a venue
            Get["venue/{id}/{name}/delete"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                return(View["delete_venue.cshtml", selectedVenue]);
            };
            // Delete a venue
            Delete["/venue/{id}/{name}/deleted"] = parameters => {
                Venue specificVenue = Venue.Find(parameters.id);
                specificVenue.Delete();
                return(View["deleted.cshtml"]);
            };

            // take you to page to delete a band
            Get["band/{id}/delete"] = parameters => {
                Band selectedBand = Band.Find(parameters.id);
                return(View["delete_band.cshtml", selectedBand]);
            };
            // Delete a band
            Delete["/band/{id}/deleted"] = parameters => {
                Band specificBand = Band.Find(parameters.id);
                specificBand.Delete();
                return(View["deleted.cshtml"]);
            };
        }
Example #22
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Venue> allVenues = Venue.GetAll();
                return(View["index.cshtml", allVenues]);
            };

            Get["/band/new"] = _ => {
                return(View["bands_venues.cshtml"]);
            };

            Post["/"] = _ => {
                Venue newVenue = new Venue(Request.Form["venue-name"]);
                newVenue.Save();
                return(View["index.cshtml", Venue.GetAll()]);
            };

            Post["/venue/{id}/band/new"] = parameters => {
                Band newBand = new Band(Request.Form["band-name"]);
                newBand.Save();
                Venue SelectedVenue = Venue.Find(parameters.id);
                SelectedVenue.AddBand(newBand);
                Dictionary <string, object> model = new Dictionary <string, object>();
                List <Band> BandList = SelectedVenue.GetBands();
                model.Add("venue", SelectedVenue);
                model.Add("bands", BandList);

                return(View["bands_venues.cshtml", model]);
            };

            Get["/venue/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Venue       SelectedVenue         = Venue.Find(parameters.id);
                List <Band> BandList = SelectedVenue.GetBands();
                model.Add("venue", SelectedVenue);
                model.Add("bands", BandList);
                return(View["bands_venues.cshtml", model]);
            };


            Post["/band/{id}/venue"] = parameters => {
                Venue newVenue = new Venue(Request.Form["venue-name"]);
                newVenue.Save();
                Band SelectedBand = Band.Find(parameters.id);
                SelectedBand.AddVenue(newVenue);
                Dictionary <string, object> model = new Dictionary <string, object>();
                List <Venue> VenueList            = SelectedBand.GetVenues();
                model.Add("band", SelectedBand);
                model.Add("venue", VenueList);

                return(View["venues_of_bands.cshtml", VenueList]);
            };

            Get["/band/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Band         SelectedBand         = Band.Find(parameters.id);
                List <Venue> VenueList            = SelectedBand.GetVenues();
                model.Add("band", SelectedBand);
                model.Add("venue", VenueList);
                return(View["venues_of_bands.cshtml", model]);
            };

            Delete["/venue/delete/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Venue SelectedVenue = Venue.Find(parameters.id);
                SelectedVenue.Delete();
                model.Add("venue", SelectedVenue);
                return(View["success.cshtml", model]);
            };

            Get["/band/delete/{id}"] = parameters => {
                Band SelectedBand = Band.Find(parameters.id);
                return(View["bands_venues.cshtml", SelectedBand]);
            };

            Patch["/venue/{id}/edit"] = parameters => {
                Venue SelectedVenue = Venue.Find(parameters.id);
                SelectedVenue.UpdateVenue(Request.Form["venue-name"]);
                return(View["success.cshtml"]);
            };


            Delete["/band/delete/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Band SelectedBand = Band.Find(parameters.id);
                SelectedBand.Delete();
                model.Add("band", SelectedBand);
                return(View["success.cshtml", model]);
            };
        }
Example #23
0
        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"]);
            };
        }
Example #24
0
        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"]);
            };
        }
Example #25
0
        public HomeModule()
        {
            //Shows --- Index Page
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };


            //BANDS --- Shows --- Entire Band List Page
            Get["/bands"] = _ => {
                List <Band> BandList = Band.GetAll();
                return(View["bands_all.cshtml", BandList]);
            };
            // BAND --- Adds --- Band to Band Added Page (popUp)
            Post["/bands"] = _ => {
                Band newBand = new Band(Request.Form["band-add"]);
                newBand.Save();
                List <Band> BandList = Band.GetAll();
                return(View["bands_all.cshtml", BandList]);
            };


            //VENUES --- Shows --- Entire Venue List Page
            Get["/venues"] = _ => {
                List <Venue> VenueList = Venue.GetAll();
                return(View["venues_all.cshtml", VenueList]);
            };
            // VENUE --- Adds --- Venue to Venue Added Page (popUp)
            Post["/venues"] = _ => {
                Venue newVenue = new Venue(Request.Form["venue-add"]);
                newVenue.Save();
                List <Venue> VenueList = Venue.GetAll();
                return(View["venues_all.cshtml", VenueList]);
            };
            // VENUE MANAGEMENT HERE -------------------------
            //VENUES --- Shows --- Venue Add Band / Edit/Delete Page
            Get["/venue/{id}/manage"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Venue       SelectedVenue         = Venue.Find(parameters.id);
                List <Band> VenueWBands           = SelectedVenue.GetBands();
                List <Band> BandList = Band.GetAll();
                model.Add("venue", SelectedVenue);
                model.Add("venuesWBands", VenueWBands);
                model.Add("bandList", BandList);
                return(View["venue_manage.cshtml", model]);
            };

            // Venue - Add band to Venue
            Post["/venues/band-added"] = _ => {
                Band  band  = Band.Find(Request.Form["band-id"]);
                Venue venue = Venue.Find(Request.Form["venue-id"]);
                venue.AddBand(band);
                return(View["success.cshtml"]);
            };

            // Venue - edit venue
            Patch["/venue/{id}/edited"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                selectedVenue.Update(Request.Form["venue-name"]);
                return(View["success.cshtml", selectedVenue]);
            };

            // Venue - delete Venue
            Delete["/venue/{id}/deleted"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                selectedVenue.Delete();
                List <Venue> AllVenues = Venue.GetAll();
                return(View["success.cshtml", AllVenues]);
            };

            /////  BAND MANAGEMENT HERE -------------
            Get["/band/{id}/manage"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Band         SelectedBand         = Band.Find(parameters.id);
                List <Venue> BandWVenues          = SelectedBand.GetVenues();
                List <Venue> VenueList            = Venue.GetAll();
                model.Add("band", SelectedBand);
                model.Add("bandsWVenues", BandWVenues);
                model.Add("venueList", VenueList);
                return(View["band_manage.cshtml", model]);
            };

            // Band - Add venue to Band
            Post["/bands/venue-added"] = _ => {
                Venue venue = Venue.Find(Request.Form["venue-id"]);
                Band  band  = Band.Find(Request.Form["band-id"]);
                band.AddVenue(venue);
                return(View["success.cshtml"]);
            };

            // Band - edit band
            Patch["/band/{id}/edited"] = parameters => {
                Band selectedBand = Band.Find(parameters.id);
                selectedBand.Update(Request.Form["band-name"]);
                return(View["success.cshtml", selectedBand]);
            };

            // Band - delete Band
            Delete["/band/{id}/deleted"] = parameters => {
                Band selectedBand = Band.Find(parameters.id);
                selectedBand.Delete();
                List <Band> AllBands = Band.GetAll();
                return(View["success.cshtml", AllBands]);
            };
        }
Example #26
0
        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);
        }