public IActionResult ShowReviews(int ActivityID) { //check for logged in state if (HttpContext.Session.GetInt32("logged_id") == null) { return(RedirectToAction("LoginReg", "LoginReg")); } //grab user and activity for front end ViewBag.LoggedUserID = (int)HttpContext.Session.GetInt32("logged_id"); Activity a = _context.Activities.Include(activity => activity.Creator).Include(activity => activity.UsersAttending).ThenInclude(ua => ua.User).Include(activity => activity.Reviews).ThenInclude(review => review.Reviewer).SingleOrDefault(activity => activity.ActivityID == ActivityID); ViewBag.Activity = a; ActivityViewModel viewModel = ActivityViewModel.GetActivityViewModel(a); return(View("ShowReviews", viewModel)); }
public IActionResult ReviewForm(int ActivityID) { //check for logged in state if (HttpContext.Session.GetInt32("logged_id") == null) { return(RedirectToAction("LoginReg", "LoginReg")); } ViewBag.LoggedUser = _context.Users.Include(user => user.AttendingActivities).ThenInclude(ua => ua.Activity).SingleOrDefault(user => (user.UserID == HttpContext.Session.GetInt32("logged_id"))); Activity a = _context.Activities.Include(activity => activity.Creator).Include(activity => activity.UsersAttending).ThenInclude(ua => ua.User).SingleOrDefault(activity => activity.ActivityID == ActivityID); ViewBag.Activity = a; ActivityViewModel viewModel = ActivityViewModel.GetActivityViewModel(a); ViewBag.FormattedDateSting = viewModel.GetlocalDateTimeString(); ViewBag.MapSource = viewModel.GetMapSrcString(); return(View("ReviewForm")); }
public IActionResult ShowActivity(int ActivityID) { if (HttpContext.Session.GetInt32("logged_id") == null) { return(RedirectToAction("LoginReg", "LoginReg")); } //logic here to check session for overlapping joined activities *********** // instantiate empty viewbag list so html won't break if no overlapp // will need to check if something is in overlapp session. If so grab it and put it in viewbag., then clear that particular session value OR set it to null? // ************* Activity a = _context.Activities.Include(activity => activity.Creator).Include(activity => activity.UsersAttending).ThenInclude(ua => ua.User).SingleOrDefault(activity => activity.ActivityID == ActivityID); ActivityViewModel viewModel = ActivityViewModel.GetActivityViewModel(a); ViewBag.LoggedUser = _context.Users.Include(user => user.AttendingActivities).ThenInclude(ua => ua.Activity).SingleOrDefault(user => (user.UserID == HttpContext.Session.GetInt32("logged_id"))); ViewBag.Activity = a; return(View("ShowActivity", viewModel)); }