// GET: WeatherDAL
        //this controller is wherer we are using thr DAL to talk to our api

        //this actionreault wil l access teh dal and create an object of the api
        public ActionResult GetWeather(int index)
        {
            WeatherDAL weatherData = new WeatherDAL();
            JObject    weather     = weatherData.GetWeatherAPI("38.4247341", "-86.9624086");

            weatherData.StartPeriodName = (string)weather["time"]["startPeriodName"][index];
            return(View());
        }
        public void GetWeatherTest()
        {
            WeatherDAL     dal      = new WeatherDAL(connectionString);
            List <Weather> forecast = dal.GetWeather("ABCD");

            Assert.IsNotNull(forecast);
            Assert.AreEqual(forecastCount, forecast.Count);
        }
Exemplo n.º 3
0
 public DateController(DateDbContext Context, IConfiguration configuration)
 {
     _context = Context;
     ed       = new EventsDAL(configuration);
     md       = new MoviesDAL(configuration);
     zd       = new ZipCodeDAL(configuration);
     pd       = new PlacesDAL(configuration);
     wd       = new WeatherDAL(configuration);
 }
Exemplo n.º 4
0
        public IActionResult Index(string ParkCode)
        {
            ParkDAL    dal  = new ParkDAL();
            WeatherDAL wDal = new WeatherDAL();

            Park           SelectedPark       = dal.GetParkByParkCode(ParkCode);
            List <Weather> Weather            = wDal.GetWeatherByParkCode(ParkCode);
            Dictionary <string, object> model = new Dictionary <string, object>();

            ViewBag.one = Weather;

            return(View(SelectedPark));
        }
Exemplo n.º 5
0
        public void GetForecastsTest()
        {
            //Arrange
            WeatherDAL weatherDAL = new WeatherDAL(connectionString);
            //string code = "XYZ";
            //string tempUnit = "f";
            List <Weather> forecasts         = new List <Weather>();
            List <Weather> expectedForecasts = new List <Weather>();

            expectedForecasts.Add(weatherobj);   //weather instantiated in TestInitialize section


            //Act
            forecasts = weatherDAL.GetForecasts("XYZ", "f");

            //Assert

            Assert.AreEqual(expectedForecasts[0].parkCode, forecasts[0].parkCode, $"{expectedForecasts[0].parkCode} should equal {expectedForecasts[0].parkCode}");
            //CollectionAssert.AreEquivalent(expectedForecasts, forecasts);
        }
Exemplo n.º 6
0
        //access ParkDAL, check temperature setting before getting weather forecast
        //TempScale is used for displaying in the view
        public ActionResult ParkDetail(string parkCode)
        {
            ParkDAL    pdal     = new ParkDAL(connectionString);
            Park       thisPark = pdal.GetParkDetail(parkCode);
            WeatherDAL wdal     = new WeatherDAL(connectionString);
            bool       celsius  = (bool)Session["Celsius"];

            if (celsius)
            {
                Weather parkForecast = wdal.GetCelsiusForecast(parkCode);
                thisPark.WeatherForecast = parkForecast;
                parkForecast.TempScale   = "C";
            }
            else
            {
                Weather parkForecast = wdal.GetForecast(parkCode);
                thisPark.WeatherForecast = parkForecast;
                parkForecast.TempScale   = "F";
            }
            return(View("ParkDetail", thisPark));
        }
        public void GetFiveDayForecastTest()
        {
            // Arrange
            // initializes a new WeatherDAL
            WeatherDAL weatherDal = new WeatherDAL(connectionString);

            // Act
            // runs the method using the fake park's parkCode as the id parameter,
            // and returns a list of weather objects
            List <Weather> parkWeather = weatherDal.GetFiveDayForecast("AAA");

            // Assert
            // checks the list of weather objects to make sure it's been populated
            // with at least 1 weather object
            Assert.IsTrue(parkWeather.Count > 0);

            // Assert
            // checks that the list of weather objects has the same parkCode as the
            // test park which we created in our Initialize method above
            Assert.AreEqual("AAA", parkWeather[0].ParkCode);
        }
Exemplo n.º 8
0
        //same as above, but switch Session variable between C and F
        public ActionResult SwitchUnits(string parkCode)
        {
            ParkDAL    pdal     = new ParkDAL(connectionString);
            Park       thisPark = pdal.GetParkDetail(parkCode);
            WeatherDAL wdal     = new WeatherDAL(connectionString);

            bool celsius = (bool)Session["Celsius"];

            if (celsius)
            {
                celsius = false;
                Weather parkForecast = wdal.GetForecast(parkCode);
                thisPark.WeatherForecast = parkForecast;
            }
            else
            {
                celsius = true;
                Weather parkForecast = wdal.GetCelsiusForecast(parkCode);
                thisPark.WeatherForecast = parkForecast;
            }
            Session["Celsius"] = celsius;

            return(RedirectToAction("ParkDetail", thisPark));
        }
 public WeatherController()
 {
     weatherDal = new WeatherDAL(connectionString);
 }