Пример #1
0
        /// <summary>
        /// Displays details of Trails
        /// </summary>
        /// <param name="id"> the id of the trail </param>
        /// <returns> returns the details of a chosen trail </returns>
        public async Task <IActionResult> Details(int id)
        {
            Trail trail = await BackendAPI.GetTrailByID(id);

            var userList = await _trail.GetAllUsers();

            var userReviews = await _trail.GetUserReviews(id);

            Weather weather = await BackendAPI.GetWeather(trail.Latitude, trail.Longitude, _configuration);

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

            foreach (var item in userList)
            {
                users.Add(new SelectListItem {
                    Text = item.UserName, Value = item.ID.ToString()
                });
            }
            ;

            TrailDetails trailDetails = new TrailDetails()
            {
                Trail        = trail,
                Users        = users,
                UserComments = userReviews,
                Weather      = weather
            };

            return(View(trailDetails));
        }
Пример #2
0
        public async Task <IActionResult> Index(string searchString)
        {
            List <Trail> trails = await BackendAPI.GetTrailsAsync(searchString);

            TrailsRootVM trailList = new TrailsRootVM
            {
                Trails = trails
            };

            return(View(trailList));
        }
Пример #3
0
        //[HttpGet]
        //public async Task<IActionResult> Edit(int ID)
        //{
        //    Trail returnTrail = await BackendAPI.GetTrailByID(ID);
        //    return View(returnTrail);
        //}

        //[HttpPost]
        //public async Task<IActionResult> Edit([Bind("TrailID, Name, Summary, Difficulty, Stars, Location, ImgMedium, Length, Ascent, Descent, High, Low, Longitude, Latitude, ConditionStatus, ConditionDetails, ConditionDate")]Trail trail)
        //{
        //    Trail returnTrail = await BackendAPI.UpdateTrailAsync(trail);
        //    return RedirectToAction();

        //}

        /// <summary>
        /// Deletes a selected trail
        /// </summary>
        /// <returns> Returns deletion confirmation </returns>
        public async Task <IActionResult> Delete(int id)
        {
            var status = await BackendAPI.DeleteTrailAsync(id);

            return(View(status));
        }
Пример #4
0
        public async Task <IActionResult> HiddenGem([Bind("Name, Summary, Difficulty, Location, ImgMedium, Length, Ascent, Descent, High, Low, Longitude, Latitude, ConditionStatus, ConditionDetails, ConditionDate")] Trail trail)
        {
            await BackendAPI.CreateTrailAsync(trail);

            return(RedirectToAction("ThankYou"));
        }