/// <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)); }
public async Task <IActionResult> Create(TrailDetails trailDetails) { UserComments comment = new UserComments() { TrailID = trailDetails.Trail.TrailID, UserInfoID = trailDetails.UserComment.UserInfoID, UserComment = trailDetails.UserComment.UserComment, }; int id = trailDetails.Trail.TrailID; await _trail.AddComment(comment); return(RedirectToAction("Details", new { id })); }
public void Setup() { m_Trail = new[] { 0, 2 }; m_TrailDetails = new TrailDetails(1, m_Trail, 1.0, 2.0, 3.0, "Type", 4.0, 5.0, 6.0); }
public void CreateOtherTrailDetailsTest() { var first = new TrailDetails(1, new int[] { }, 2000.0, 3000.0, 4000.0, "Type", 5.0, 6.0, 7.0); var other = new TrailDetails(10, new int[] { }, 200.0, 300.0, 400.0, "Other Type", 5.0, 6.0, 7.0); m_Model.CreateOtherTrailDetails(first, other); m_Factory.Received().Create(other.Interation, other.Trail, other.Length, 1800.0, 90.0, other.Type, other.Alpha, other.Beta, other.Gamma); }