public async Task <VirtualTourViewModel> GetVirtualTourViewModel(int courseId, string sessionUsername) { var virtualTourViewModel = new VirtualTourViewModel(); var golfCourseHoleVideosAndGenInfo = await _golfCourseRepository.GetGolfCourseAndCourseVideoInfo(courseId); var golfCourseHoleReviews = await _golfCourseRepository.GetGolfCourseReviews(courseId); virtualTourViewModel.GolfCourseId = golfCourseHoleVideosAndGenInfo.Item1.Id; virtualTourViewModel.GolfCourseName = golfCourseHoleVideosAndGenInfo.Item1.Name; virtualTourViewModel.GolfCoursePhone = golfCourseHoleVideosAndGenInfo.Item1.PhoneNumber; virtualTourViewModel.GolfCourseAddress = golfCourseHoleVideosAndGenInfo.Item1.Address; virtualTourViewModel.GolfCourseType = golfCourseHoleVideosAndGenInfo.Item1.Type; virtualTourViewModel.GolfCourseOwnerId = golfCourseHoleVideosAndGenInfo.Item1.UserId; if (sessionUsername == string.Empty) { virtualTourViewModel.CanRate = false; virtualTourViewModel.CanDeleteRating = false; } else { virtualTourViewModel.CanRate = true; virtualTourViewModel.CanDeleteRating = true; } virtualTourViewModel.GolfCourseHoleVideos = (List <CourseVideoViewModel>) MapVideoDataToVideoViewModelList(golfCourseHoleVideosAndGenInfo.Item2); virtualTourViewModel.GolfCourseHoleRatings = (List <GolfCourseHoleRatingViewModel>) MapCourseReviewDataToViewModelList(golfCourseHoleReviews, sessionUsername); return(virtualTourViewModel); }
public async Task <ActionResult> VirtualTour(int golfCourseId) { VirtualTourViewModel vm = null; if (Session["Username"] == null) { vm = await _golfCourseService.GetVirtualTourViewModel(golfCourseId, string.Empty); } else { vm = await _golfCourseService.GetVirtualTourViewModel(golfCourseId, Session["Username"].ToString()); } return(View(vm)); }