예제 #1
0
        public ActionResult Weather(string id)
        {
            IParkDAL       DAL      = new ParkSqlDAL();
            List <Park>    ParkList = DAL.getAllParksData();
            List <Weather> weather  = new List <Weather>();

            foreach (Park p in ParkList)
            {
                if (id == p.ParkCode)
                {
                    IWeatherDAL thisDAL = new WeatherSqlDAL();
                    weather = thisDAL.getWeatherByParkCode(p.ParkCode);
                }
            }

            bool isFaranheight;

            Session["Tempature"] = Request.Params["Tempature"];
            if (Session["Tempature"] != null)
            {
                if (Session["Tempature"].ToString() == "F")
                {
                    isFaranheight = true;
                }
                else
                {
                    isFaranheight = false;
                }
            }
            else
            {
                isFaranheight = true;
            }
            // update to Faranheight or Celcius
            for (int i = 0; i < weather.Count; i++)
            {
                if (isFaranheight)
                {
                    if (weather[i].Tempature == "F")
                    {
                        continue;
                    }
                    else
                    {
                        weather[i].Tempature = "F";
                        weather[i].High      = ChangeFaranheightToCelcius(weather[i].High, "F");
                        weather[i].Low       = ChangeFaranheightToCelcius(weather[i].Low, "F");
                    }
                }
                else
                {
                    weather[i].Tempature = "C";
                    weather[i].High      = ChangeFaranheightToCelcius(weather[i].High, "C");
                    weather[i].Low       = ChangeFaranheightToCelcius(weather[i].Low, "C");
                }
            }

            return(View("Weather", weather));
        }
예제 #2
0
        // GET: Home/Parklist
        public ActionResult ParkList()
        {
            Session["ParkList"] = "active";
            IParkDAL    DAL   = new ParkSqlDAL();
            List <Park> model = DAL.getAllParksData();

            return(View("ParkList", model));
        }
예제 #3
0
        public void ParkSqlDAL_GetAllParks_Test()
        {
            //Arrange
            IParkDAL parkDAL = new ParkSqlDAL();
            //Act
            List <Park> allParks = parkDAL.getAllParksData();

            //Assert
            Assert.IsNotNull(parkDAL);
            Assert.IsNotNull(allParks);
            Assert.AreEqual(10, allParks.Count);
        }
예제 #4
0
        public ActionResult ParkDetails(string id)
        {
            IParkDAL    DAL      = new ParkSqlDAL();
            List <Park> ParkList = DAL.getAllParksData();
            Park        model    = null;

            foreach (Park p in ParkList)
            {
                if (id == p.ParkCode)
                {
                    model = p;
                }
            }
            return(View("ParkDetails", model));
        }