コード例 #1
0
        public String getSecondList(String filmName)
        {
            String htmlList;

            LocationListUI loc = new LocationFinder().getLocationsForFilm(filmName);

            htmlList = "";
            foreach (String location in loc.locations)
            {
                htmlList = htmlList + "<option>" + location + "</option>";
            }

            return htmlList;
        }
コード例 #2
0
        public void readAllFilmsTest()
        {
            LocnXMLReader target = new LocnXMLReader();

            // Context db = new Context();
            // db.Database.Delete();
            // db.Database.Create();

            target.setSource("https://nycopendata.socrata.com/download/qb3k-n8mm/application/xml");
            List<FilmLocations> filmList = target.readAllFilms();

            LocationFinder locFinder = new LocationFinder();
            bool film25thHourFound = false;
            bool filmAThousandClownsFound = false;
            foreach (String film in locFinder.getAllFilmNames())
            {
                if (film == "25th Hour")
                    film25thHourFound = true;
                else if (film == "A Thousand Clowns")
                    filmAThousandClownsFound = true;
            }
            Assert.AreEqual(film25thHourFound, true);
            Assert.AreEqual(filmAThousandClownsFound, true);

            LocationListUI locList = locFinder.getLocationsForFilm("25th Hour");
            bool foundLoc1 = false;
            bool foundLoc2 = false;
            foreach (String locText in locList.locations)
            {
                if (locText == "World Trade Center, Lower Manhattan")
                    foundLoc1 = true;
                else if (locText == "Carl Schurz Park, Upper East Side, Manhattan")
                    foundLoc2 = true;
                else
                    Assert.Fail("Unexpected location in film 25th Hour " + locText);
            }
            Assert.AreEqual(foundLoc1, true);
            Assert.AreEqual(foundLoc2, true);

            locList = locFinder.getLocationsForFilm("A Thousand Clowns");
            foundLoc1 = false;
            foreach (String locText in locList.locations)
            {
                if (locText == "Statue of Liberty, Liberty Island, New York Harbor")
                    foundLoc1 = true;
                else
                    Assert.Fail("Unexpected location in film A Thousand Clowns " + locText);
            }
            Assert.AreEqual(foundLoc1, true);
        }
コード例 #3
0
        public void getLocationsForFilmTest()
        {
            LocationFinder target = new LocationFinder();
            String filmName;
            LocationListUI expected, actual;

            filmName = "12 Angry Men";
            expected = new LocationListUI();
            expected.filmName = filmName;
            expected.locations = new List<String>();
            expected.locations.Add ("New York County Courthouse<br>40 Foley Square<br>Lower Manhattan");
            actual = target.getLocationsForFilm(filmName);
            Assert.AreEqual(expected, actual);

            filmName = "15 Minutes";
            expected = new LocationListUI();
            expected.filmName = filmName;
            expected.locations = new List<String>();
            expected.locations.Add("E. 60-66th St.and Madison Ave.<br>Upper East Side<br>Manhattan");
            expected.locations.Add("Carl Schurz Park<br>Upper East Side<br>Manhattan");
            actual = target.getLocationsForFilm(filmName);
            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to an Awesome Enterprise App!";

               Context db = new Context();
               if (!db.Database.Exists())
               db.Database.Create();
            // db.Database.Delete();
               // db.Database.Create();

            //LocationCalculator target = new LocationCalculator(); // TODO: Initialize to an appropriate value
            //double distance = 0.94;
            //// 49-51 W 46th St
            //target.xCentre = 40.756912;
            //target.yCentre = -73.980989;

            //// 4-42 W 58th St
            //target.xLocation = 40.764259;
            //target.yLocation = -73.975325;

            //target.radius = 1; //km

            //Boolean x = target.isInsideRadius();

            new APIReader().readAPI();

            List<String> films = new LocationFinder().getAllFilmNames();

            List<SelectListItem> movies = new List<SelectListItem>();

            foreach (String title in films)
            {

                movies.Add(new SelectListItem { Text = title });

            }

            /* selectedFilmLocations selected = new selectedFilmLocations();

                 foreach(Select in selected)
                     {

                     movies.Add(new SelectListItem { Text = film });

                      }

              public int getSelectedItemId()
              {
              int index = ;
              return index = null;
              }

               int index = movies.;
              */
            LocationListUI locations = new LocationFinder().getLocationsForFilm(films[0]);

            List<SelectListItem> locations2 = new List<SelectListItem>();

            foreach (String loc in locations.locations)
            {
                locations2.Add(new SelectListItem { Text = loc });
            }

            /*
                 List<SelectListItem> radius = new List<SelectListItem>();

                 String [] radiusVals = { "1km", "2kms", "3kms", "4kms", "5kms" };

                     foreach(String radiusVal in radiusVals)
                     {
                         radius.Add(new SelectListItem { Text = radiusVal });
                     }

                   */

            ViewData["movieList"] = movies;

            ViewData["locationList"] = locations2;

            // ViewData["radiusList"] = radius;

            return View();
        }