예제 #1
0
        public void Band_Update_UpdatesInDb()
        {
            Band testBand = new Band("Name");

            testBand.Save();
            testBand.Update("new Name");

            Band newBand = new Band("new Name", testBand.GetId());

            Assert.Equal(testBand, newBand);
        }
예제 #2
0
        public void Test_Update_UpdateBandInDataBase()
        {
            //Arrange
            Band testBand = new Band("The Mars Volta");

            testBand.Save();
            string newBandName = "Good Tiger";

            //Act
            testBand.Update(newBandName); //Simplistic for MVP:(
            string result = testBand.GetName();

            //Assert
            Assert.Equal(newBandName, result);
        }
예제 #3
0
        public void Test_Update_UpdatesBandInDatabase()
        {
            //Arrange
            Band testBand = new Band("Reo", "rock");

            testBand.Save();
            string newName = "journey";

            //Act
            testBand.Update("journey", "rock");
            string result = testBand.GetName();

            //Assert
            Assert.Equal(newName, result);
        }
예제 #4
0
        public void Test_Update_UpdatesBandInDatabase()
        {
            Band testBand = new Band("Some Band Name", "Some Band Description");

            testBand.Save();

            string newName        = "nano.RIPE";
            string newDescription = "A Japanese pop rock band with two core members.";

            testBand.Update(newName, newDescription);

            Band result   = Band.GetAll()[0];
            Band expected = new Band(newName, newDescription, testBand.Id);

            Assert.Equal(expected, result);
        }
예제 #5
0
        public void Update_OneBand_NewName()
        {
            Band testBand1 = new Band("band1");

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

            testBand2.Save();

            testBand1.Update("band11");

            string newName = testBand1.GetName();
            string result  = "band11";

            Assert.Equal(newName, result);
        }
예제 #6
0
        public void Test_Update_UpdateBandInDatabase()
        {
            //Arrange
            Band newBand = new Band("Metallica");

            newBand.Save();

            string newName = "ColdPlay";

            //Act
            newBand.Update(newName);
            string result = newBand.GetName();

            //Assert.Equal
            Assert.Equal(newName, result);
        }
예제 #7
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]);
            };
        }
예제 #8
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]);
            };
        }
예제 #9
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]);
            };
        }
예제 #10
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"]);
            };
        }
예제 #11
0
 public void Test_UpDateInDatabase()
 {
     //Arrange
       DateTime testTime = new DateTime(2016, 1, 1);
       string testName = "A";
       Band testBand = new Band(testName,testTime);
       testBand.Save();
       testBand.Update("B",testTime);
       //Act
       //Assert
       Assert.Equal("B", testBand.GetName());
 }