public IActionResult UpdateWeddingForm(int wid) { int?id = HttpContext.Session.GetInt32(ID); if (id.HasValue) // check id is in session { var wedding = dbContext.GetWedding(wid); return(View("UpdateWeddingForm", wedding)); } else { return(Redirect("/logout")); } }