public ActionResult Edit(int id) { using (BLLContext ctx = new BLLContext()) { List <RoleBO> items = ctx.GetAllRoles(); List <SelectListItem> myRoles = new List <SelectListItem>(); foreach (RoleBO item in items) { SelectListItem itm = new SelectListItem(); itm.Value = item.RoleID.ToString(); itm.Text = item.Role; myRoles.Add(itm); } ViewBag.MyRoles = myRoles; UserBO user = ctx.GetUserByID(id); if (user != null) { if ((user.UserName == User.Identity.Name) || User.IsInRole("Moderator") || User.IsInRole("Administrator")) { return(View(user)); } // need to finish logic to send message that user isn't this user TempData["message"] = "This ain't your stuff."; return(RedirectToAction("Login", "Home")); } // need to finish logic to send message that user isn't in database TempData["message"] = "The URL entered is invalid. Please log in and follow the links"; return(RedirectToAction("Login", "Home")); } }