Ejemplo n.º 1
0
        public void Test_GetBands_GetBandsOfVenue()
        {
            Band hardy = new Band("hardy");

            hardy.Save();
            Band testBand = new Band("testBand");

            testBand.Save();
            Venue testVenue = new Venue("testVenue");

            testVenue.Save();
            testVenue.AddBand(hardy);
            testVenue.AddBand(testBand);
            List <Band> expected = new List <Band> {
                hardy, testBand
            };
            List <Band> actual = testVenue.GetBands();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 2
0
        public void Test_PlayingInVenue_True()
        {
            Band tempBand = new Band("temp");

            tempBand.Save();
            Venue testVenue = new Venue("test");

            testVenue.Save();
            testVenue.AddBand(tempBand);
            Assert.Equal(true, Band.PlayingInVenue(tempBand.GetId()));
        }
Ejemplo n.º 3
0
        public void Test_GetVenues()
        {
            Band tempBand = new Band("temp");

            tempBand.Save();
            Venue tempVenue  = new Venue("venue1");
            Venue tempVenue2 = new Venue("venue2");

            tempVenue.Save();
            tempVenue2.Save();
            tempVenue.AddBand(tempBand);
            tempVenue2.AddBand(tempBand);
            List <Venue> expected = new List <Venue> {
                tempVenue, tempVenue2
            };
            List <Venue> actual = tempBand.GetVenues();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 4
0
        public void Test_GetBandsAssociatedWithVenue()
        {
            List <Band> allBands  = new List <Band> {
            };
            List <Band> testBands = new List <Band> {
            };

            Venue newVenue = new Venue("Roseland");

            newVenue.Save();

            Band newBand = new Band("ExampleBand");

            newBand.Save();

            newVenue.AddBand(newBand);
            allBands = newVenue.GetBands();
            testBands.Add(newBand);

            Assert.Equal(testBands, allBands);
        }
Ejemplo n.º 5
0
 public HomeModule()
 {
     Get["/"] = _ =>
     {
         return(View["index.cshtml"]);
     };
     Get["/add-new-band"] = _ =>
     {
         return(View["add-new-band.cshtml"]);
     };
     Post["/added-band"] = _ =>
     {
         string bandName = Request.Form["band-name"];
         Band   newBand  = new Band(bandName);
         newBand.Save();
         return(View["added-band.cshtml", bandName]);
     };
     Get["/add-new-venue"] = _ =>
     {
         return(View["add-new-venue.cshtml"]);
     };
     Post["/added-venue"] = _ =>
     {
         string venueName = Request.Form["venue-name"];
         Venue  newVenue  = new Venue(venueName);
         newVenue.Save();
         return(View["added-venue.cshtml", newVenue]);
     };
     Get["/view-all-venues"] = _ =>
     {
         List <Venue> allVenues = new List <Venue> {
         };
         allVenues = Venue.GetAll();
         return(View["view-all-venues.cshtml", allVenues]);
     };
     Get["/view-all-bands"] = _ =>
     {
         List <Band> allBands = new List <Band> {
         };
         allBands = Band.GetAll();
         return(View["view-all-bands.cshtml", allBands]);
     };
     Get["/venue/{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["/band/{id}"] = parameters =>
     {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Band         selectedBand         = Band.Find(parameters.id);
         List <Venue> VenueBands           = selectedBand.GetVenues();
         List <Venue> allVenues            = Venue.GetAll();
         model.Add("band", selectedBand);
         model.Add("VenueBands", VenueBands);
         model.Add("allVenues", allVenues);
         return(View["band.cshtml", model]);
     };
     Post["/band/add_venue"] = _ =>
     {
         Band  band  = Band.Find(Request.Form["band-id"]);
         Venue venue = Venue.Find(Request.Form["venue-id"]);
         band.AddVenue(venue);
         List <Band> allBands = new List <Band> {
         };
         allBands = Band.GetAll();
         return(View["view-all-bands.cshtml", allBands]);
     };
     Post["/venue/add_band"] = _ =>
     {
         Venue venue = Venue.Find(Request.Form["venue-id"]);
         Band  band  = Band.Find(Request.Form["band-id"]);
         venue.AddBand(band);
         List <Venue> allVenues = new List <Venue> {
         };
         allVenues = Venue.GetAll();
         return(View["view-all-venues.cshtml", allVenues]);
     };
 }
Ejemplo n.º 6
0
        public HomeModule()
        {
            Get["/"]          = _ => View["index.cshtml"];
            Get["/add-band"]  = _ => View["add-band.cshtml"];
            Get["/add-venue"] = _ => View["add-venue.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["/band/{id}"] = parameters =>
            {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Band         selectedBand         = Band.Find(parameters.id);
                List <Venue> venues    = selectedBand.GetVenues();
                List <Venue> allVenues = Venue.GetAll();
                model.Add("band", selectedBand);
                model.Add("venues", venues);
                model.Add("allVenues", allVenues);
                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> Bands    = selectedVenue.GetBands();
                List <Band> allBands = Band.GetAll();
                model.Add("venue", selectedVenue);
                model.Add("bands", Bands);
                model.Add("allBands", allBands);
                return(View["venue.cshtml", model]);
            };

            Post["/band/associate-venue"] = _ =>
            {
                Band  band  = Band.Find(Request.Form["band-id"]);
                Venue venue = Venue.Find(Request.Form["venue-id"]);
                band.AddVenue(venue);
                List <Band> allBands = new List <Band> {
                };
                allBands = Band.GetAll();
                return(View["bands.cshtml", allBands]);
            };

            Post["/venue/associate-band"] = _ =>
            {
                Venue venue = Venue.Find(Request.Form["venue-id"]);
                Band  band  = Band.Find(Request.Form["band-id"]);
                venue.AddBand(band);
                List <Venue> allVenues = new List <Venue> {
                };
                allVenues = Venue.GetAll();
                return(View["venues.cshtml", allVenues]);
            };

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

            Post["/band-added"] = _ => {
                string name    = Request.Form["name"];
                Band   newBand = new Band(name);
                newBand.Save();
                return(View["band-added.cshtml", name]);
            };

            Post["/band-deleted/{id}"] = parameters => {
                Band   toDelete = Band.Find(parameters.id);
                string name     = toDelete.GetName();
                Band.RemoveABand(parameters.id);
                return(View["band-deleted.cshtml", name]);
            };

            Post["/venue-deleted/{id}"] = parameters => {
                Venue  toDelete = Venue.Find(parameters.id);
                string name     = toDelete.GetName();
                Venue.RemoveAVenue(parameters.id);
                return(View["venue-deleted.cshtml", name]);
            };

            Post["/band-updated/{id}"] = parameters => {
                string newName = Request.Form["name"];
                Band.Update(newName, parameters.id);
                return(View["band-updated.cshtml", newName]);
            };

            Post["/venue-updated/{id}"] = parameters => {
                string newName = Request.Form["name"];
                string newCity = Request.Form["city"];
                Venue.Update(newName, newCity, parameters.id);
                return(View["venue-updated.cshtml", newName]);
            };
        }
Ejemplo n.º 7
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };

            Delete["/"] = _ => {
                Band.DeleteAll();
                Venue.DeleteAll();
                return(View["index.cshtml"]);
            };

            Get["/venues"] = _ => {
                return(View["venue-management.cshtml", Venue.GetAll()]);
            };

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

            Delete["/venues"] = _ => {
                Venue       foundVenue   = Venue.Find(Request.Form["venue-id"]);
                List <Band> bandsOfVenue = foundVenue.GetBands();
                foundVenue.DeleteSingle();
                foreach (var band in bandsOfVenue)
                {
                    if (!Band.PlayingInVenue(band.GetId()))
                    {
                        band.DeleteSingle();
                    }
                }
                return(View["venue-management", Venue.GetAll()]);
            };

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

            Post["/venues/{id}"] = parameter => {
                Venue foundVenue = Venue.Find(parameter.id);
                Band  newBand    = new Band(Request.Form["band-name"]);
                if (!Band.CheckExistence(newBand.GetName()))
                {
                    newBand.Save();
                    foundVenue.AddBand(newBand);
                }
                else
                {
                    Band foundBand = Band.FindByName(Request.Form["band-name"]);
                    foundVenue.AddBand(foundBand);
                }
                return(View["single-venue.cshtml", foundVenue]);
            };

            Delete["/venues/{id}"] = parameter => {
                Venue foundVenue = Venue.Find(parameter.id);
                Band  foundBand  = Band.Find(Request.Form["band-id"]);
                foundVenue.DeleteBandFromVenue(foundBand);
                if (!Band.PlayingInVenue(foundBand.GetId()))
                {
                    foundBand.DeleteSingle();
                }
                return(View["single-venue.cshtml", foundVenue]);
            };

            Patch["/venues/{id}"] = parameter => {
                Venue foundVenue = Venue.Find(parameter.id);
                foundVenue.Update(Request.Form["venue-name"]);
                return(View["single-venue.cshtml", foundVenue]);
            };

            Get["/bands"] = _ => {
                return(View["band-management.cshtml", Band.GetAll()]);
            };
        }