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")); } }
// GET: User/Details/5 public ActionResult Details(int id) { using (BLLContext ctx = new BLLContext()) { UserBO user = ctx.GetUserByID(id); return(View(user)); } }
// GET: UserCharacter/Edit/5 public ActionResult Edit(int id) { using (BLLContext ctx = new BLLContext()) { UserCharacterBO character = ctx.GetUserCharacter(id); UserBO user = ctx.GetUserByID(character.UserID_FK); if ((user.UserName == User.Identity.Name) || User.IsInRole("Moderator") || User.IsInRole("Administrator")) { return(View(character)); } TempData["message"] = "This ain't your personalized character."; return(RedirectToAction("Login", "Home")); } }
// GET: UserCharacter/Delete/5 public ActionResult Delete(int id) { using (BLLContext ctx = new BLLContext()) { //UserCharacterBO uChar = ctx.GetUserCharacter(id); //return View(uChar); UserCharacterBO character = ctx.GetUserCharacter(id); if (character != null) { UserBO user = ctx.GetUserByID(character.UserID_FK); if ((user.UserName == User.Identity.Name) || User.IsInRole("Moderator") || User.IsInRole("Administrator")) { return(View(character)); } // need to finish logic to send message that user isn't this user TempData.Remove("Message"); TempData["Message"] = "This ain't your personalized character."; return(RedirectToAction("Login", "Home")); } return(View("Error")); } }