// GET: Post/Details/5 public async Task <IActionResult> Details(int?PostId) { if (HttpContext.Session.GetInt32("UserId") == null || HttpContext.Session.GetInt32("UserId") == 0) { TempData["Message"] = "You must be logged in to access that page"; return(RedirectToAction("SignIn", "User")); } ViewBag.UserId = HttpContext.Session.GetInt32("UserId"); ViewBag.Username = HttpContext.Session.GetString("Username"); ViewBag.DriverId = HttpContext.Session.GetInt32("DriverId"); if (PostId == null) { return(NotFound()); } Post post = await _postLogic.GetSinglePost(PostId); if (post == null) { return(NotFound()); } return(View(post)); }