Пример #1
0
 public void Dispose()
 {
     Band.DeleteAll();
     Venue.DeleteAll();
     Genre.DeleteAll();
 }
Пример #2
0
 public void Dispose()
 {
     Venue.DeleteAll();
     Band.DeleteAll();
     Performance.DeleteAll();
 }
Пример #3
0
 // a method to delete records between tests
 public void Dispose()
 {
     Venue.DeleteAll();
     Band.DeleteAll();
 }
Пример #4
0
        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);
                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["/bands/delete"] = _ => {
                Band.DeleteAll();
                return(View["cleared.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["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["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"]);
            };

            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["success.cshtml"]);
            };

            Post["/venues/delete"] = _ => {
                Venue.DeleteAll();
                return(View["cleared.cshtml"]);
            };

            Get["/contact"] = _ => {
                return(View["contact.cshtml"]);
            };
        }
Пример #5
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]);
            };
        }
Пример #6
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"]);
            };
        }
Пример #7
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"] = _ => {
                return(View["band_form.cshtml"]);
            };
            Get["/venues/new"] = _ => {
                return(View["venue_form.cshtml"]);
            };
            Post["/bands/new"] = _ => {
                string name = Request.Form["name"];
                name.ToLower();
                string nameTitleCasename = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name);
                Band   newBand           = new Band(nameTitleCasename, Request.Form["type"]);
                newBand.Save();
                List <Band> AllBands = Band.GetAll();
                return(View["bands.cshtml", AllBands]);
            };
            Post["/venues/new"] = _ => {
                Venue newVenue = new Venue(Request.Form["name"], Request.Form["location"], Request.Form["capacity"]);
                newVenue.Save();
                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 venues       = selectedBand.GetVenue();
                var AllVenues    = Venue.GetAll();
                model.Add("band", selectedBand);
                model.Add("venues", venues);
                model.Add("AllVenues", AllVenues);
                return(View["band.cshtml", model]);
            };
            Get["/venues/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var selectedVenue = Venue.Find(parameters.id);
                var bandsAtVenue  = selectedVenue.GetBand();
                var AllBands      = Band.GetAll();
                model.Add("venue", selectedVenue);
                model.Add("bands", bandsAtVenue);
                model.Add("allBands", AllBands);
                return(View["venue.cshtml", model]);
            };
            Get["bands/{id}/venue"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var AllVenues    = Venue.GetAll();
                var selectedBand = Band.Find(parameters.id);
                model.Add("AllVenues", AllVenues);
                model.Add("band", selectedBand);
                return(View["band_venue_form.cshtml", model]);
            };
            Post["bands/{id}/venue"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Venue selectedVenue = Venue.Find(int.Parse(Request.Form["venue"]));
                var   selectedBand  = Band.Find(parameters.id);
                selectedBand.AddVenue(selectedVenue);
                var venues    = selectedBand.GetVenue();
                var AllVenues = Venue.GetAll();
                model.Add("band", selectedBand);
                model.Add("venues", venues);
                model.Add("AllVenues", AllVenues);
                return(View["band.cshtml", model]);
            };
            Get["venues/{id}/band"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var AllBands      = Band.GetAll();
                var selectedVenue = Venue.Find(parameters.id);
                model.Add("AllBands", AllBands);
                model.Add("venue", selectedVenue);
                return(View["venue_band_form.cshtml", model]);
            };
            Post["venues/{id}/band"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Band selectedBand  = Band.Find(int.Parse(Request.Form["band"]));
                var  selectedVenue = Venue.Find(parameters.id);
                selectedVenue.AddBand(selectedBand);
                var bands    = selectedVenue.GetBand();
                var AllBands = Band.GetAll();
                model.Add("venue", selectedVenue);
                model.Add("bands", bands);
                model.Add("AllBands", AllBands);
                return(View["venue.cshtml", model]);
            };
            Get["venues/edit/{id}"] = parameters => {
                Venue selectedVenue = Venue.Find(parameters.id);
                return(View["venue_edit.cshtml", selectedVenue]);
            };
            Patch["/venues/edit/{id}"] = parameters => {
                Venue SelectedVenue = Venue.Find(parameters.id);
                SelectedVenue.Update(Request.Form["name"], Request.Form["location"], int.Parse(Request.Form["capacity"]));
                return(View["success.cshtml"]);
            };
            Get["venues/delete/{id}"] = parameters => {
                Venue SelectedVenue = Venue.Find(parameters.id);
                return(View["venue_delete.cshtml", SelectedVenue]);
            };
            Delete["venues/delete/{id}"] = parameters => {
                Venue SelectedVenue = Venue.Find(parameters.id);
                SelectedVenue.Delete();
                return(View["success.cshtml"]);
            };

            Post["/bands/clear"] = _ => {
                Band.DeleteAll();
                List <Band> AllBand = Band.GetAll();
                return(View["bands.cshtml", AllBand]);
            };
            Post["/venues/clear"] = _ => {
                Venue.DeleteAll();
                List <Venue> AllVenue = Venue.GetAll();
                return(View["venues.cshtml", AllVenue]);
            };
        }
Пример #8
0
 public void Dispose()
 {
     // Venue.DeleteAll();
     Venue.DeleteAll();
 }
Пример #9
0
 public void Dispose()
 {
     Band.DeleteAll();
     Venue.DeleteAll();
     Venue.DeleteRelationship();
 }
Пример #10
0
        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]);
            };
        }
Пример #11
0
        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 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]);
     };
 }