示例#1
0
        public List <ParkDetail> GetParkByAcreage(int minacreage, int maxacreage)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var parks = ctx.Parks.Where(e => e.Acreage >= minacreage && e.Acreage <= maxacreage).ToList();
                foreach (var park in parks)
                {
                    var foundPark = new ParkDetail
                    {
                        ID                 = park.ID,
                        Name               = park.Name,
                        CityID             = park.CityID,
                        CityName           = park.City.Name,
                        StateID            = park.City.StateID,
                        StateName          = park.City.State.Name,
                        Acreage            = park.Acreage,
                        Hours              = park.Hours,
                        PhoneNumber        = park.PhoneNumber,
                        Website            = park.Website,
                        AverageTrailRating = park.AverageTrailRating
                    };
                    searchResults.Add(foundPark);
                }
            }

            return(searchResults);
        }
        public ActionResult Detail(string parkCode)
        {
            Park           park    = _parksDal.GetOnePark(parkCode);
            List <Weather> weather = new List <Weather>();

            if (Session["WeatherData"] == null)
            {
                weather = _parksDal.RetrieveOneParkWeather(parkCode);
            }
            else
            {
                if ((string)Session["ParkCode"] == parkCode)
                {
                    weather = (List <Weather>)Session["WeatherData"];
                }
                else
                {
                    int scale = 0;
                    if ((string)Session["TempScale"] == "Celsius")
                    {
                        scale = 1;
                    }

                    return(RedirectToAction("TempScaleChoice", new { scale = scale, parkCode = parkCode }));
                }
            }
            ParkDetail parkDetail = new ParkDetail();

            parkDetail.PopulateParkProperties(park);
            parkDetail.PopulateForecast(weather);
            return(View("Detail", parkDetail));
        }
示例#3
0
 public void Delete(ParkDetail objParkDetail)
 {
     objParkDetail.DateModified = DateTime.Now;
     objParkDetail.IsDeleted    = true;
     _context.Update(objParkDetail);
     _context.SaveChanges();
 }
示例#4
0
 public void Add(ParkDetail objParkDetail)
 {
     objParkDetail.DateCreated  = DateTime.Now;
     objParkDetail.DateModified = DateTime.Now;
     _context.ParkDetails.Add(objParkDetail);
     _context.SaveChanges();
 }
        public void WhenIClickOnAParkPicture()
        {
            ParkList listPage = ScenarioContext.Current.Get <ParkList>("CurrentPage");

            ParkDetail detailPage = listPage.ClickImage_GetDetail();

            ScenarioContext.Current.Set(detailPage, "CurrentPage");
        }
        public void ClickPark_GetDetailView()
        {
            ParkList page = new ParkList(driver);

            page.Navigate();

            ParkDetail result = page.ClickImage_GetDetail();

            Assert.IsNotNull(result);
        }
        public void ClickParkImage()
        {
            HomePage homePage = new HomePage(driver);

            homePage.Navigate();

            ParkDetail parkDetail = homePage.ClickImage();

            Assert.AreEqual("img", parkDetail.Id.TagName);
        }
        //GET BY ID
        public async Task <ParkDetail> GetParkByIdAsync(int parkId)
        {
            //Search Database by Id for Park
            var entity = await _context.Parks.FindAsync(parkId);

            if (entity == null)
            {
                throw new Exception("No Park found.");
            }
            //Turn the entity into the Detail

            var model = new ParkDetail
            {
                ParkId = entity.ParkId,
                Name   = entity.Name,
                City   = entity.City,
                State  = entity.State,
                Rides  = entity.Rides.Select(ride => new RideListItem
                {
                    RideId         = ride.RideId,
                    MinRiderHeight = ride.MinRiderHeight,
                    Name           = ride.Name,
                    Type           = ride.Type,
                    AverageRating  = ride.AverageRating
                }).ToList(),
            };

            foreach (var rating in entity.Ratings)
            {
                model.Ratings.Add(new ParkRatingListItem
                {
                    RatingId    = rating.RatingId,
                    ParkId      = rating.ParkId,
                    ParkName    = rating.Park.Name,
                    Description = rating.Description,
                    IsUserOwned = rating.UserId == _userId,
                    Score       = rating.Score,
                    VisitDate   = rating.VisitDate
                });
            }

            //return the detail model
            return(model);
        }
        public IActionResult Detail(string id)
        {
            ParkDetail park = new ParkDetail()
            {
                Park            = this.parkDao.GetPark(id),
                FiveDayForecast = this.parkDao.GetForecast(id)
            };

            if (this.HttpContext.Session.Get <string>("unit") == "C")
            {
                foreach (DailyWeather forecast in park.FiveDayForecast)
                {
                    forecast.LowDisplay  = (int)((forecast.Low - 32) / 1.8);
                    forecast.HighDisplay = (int)((forecast.High - 32) / 1.8);
                }
            }

            return(this.View(park));
        }
        /// <summary>
        /// Takes the user to the SurveyResults page if they have filled out the survey form correctly.
        /// </summary>
        /// <returns>Results view page or return to previous view.</returns>
        public IActionResult SurveyResult()
        {
            IList <Park>       parks = this.parkDao.GetParks();
            IList <ParkDetail> model = new List <ParkDetail>();

            foreach (Park park in parks)
            {
                ParkDetail pd = new ParkDetail()
                {
                    Park    = park,
                    Surveys = this.parkDao.GetSurveys(park.ParkCode)
                };

                model.Add(pd);
            }

            var parksInOrder = model.OrderBy(park => park.Surveys.Count).ToList <ParkDetail>();

            parksInOrder.Reverse();
            return(this.View(parksInOrder));
        }
        public ParkDetail GetParkDetails(string parkCode)
        {
            ParkDetail p = new ParkDetail();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("SELECT * FROM park WHERE parkCode = @parkCode;", conn);
                    cmd.Parameters.AddWithValue("@parkCode", parkCode);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        p.ParkCode           = Convert.ToString(reader["parkCode"]);
                        p.Name               = Convert.ToString(reader["parkName"]);
                        p.Location           = Convert.ToString(reader["state"]);
                        p.Description        = Convert.ToString(reader["parkDescription"]);
                        p.Acreage            = Convert.ToInt32(reader["acreage"]);
                        p.Elevation          = Convert.ToInt32(reader["elevationInFeet"]);
                        p.MilesOfTrail       = Convert.ToDouble(reader["milesOfTrail"]);
                        p.NumOfCampsites     = Convert.ToInt32(reader["numberOfCampsites"]);
                        p.Climate            = Convert.ToString(reader["climate"]);
                        p.YearFounded        = Convert.ToInt32(reader["yearFounded"]);
                        p.AnnualVisitors     = Convert.ToInt32(reader["annualVisitorCount"]);
                        p.Quote              = Convert.ToString(reader["inspirationalQuote"]);
                        p.QuoteSource        = Convert.ToString(reader["inspirationalQuoteSource"]);
                        p.EntryFee           = Convert.ToInt32(reader["entryFee"]);
                        p.NumOfAnimalSpecies = Convert.ToInt32(reader["numberOfAnimalSpecies"]);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }

            return(p);
        }
        public void ThenIShouldSeeTheParkDetailPage()
        {
            ParkDetail detailPage = ScenarioContext.Current.Get <ParkDetail>("CurrentPage");

            Assert.IsNotNull(detailPage);
        }
示例#13
0
        public IActionResult Detail(string parkCode)
        {
            ParkDetail park = parkDAL.GetParkDetails(parkCode);

            return(View(park));
        }
示例#14
0
 public void Update(ParkDetail objParkDetail)
 {
     objParkDetail.DateModified = DateTime.Now;
     _context.Update(objParkDetail);
     _context.SaveChanges();
 }