コード例 #1
0
        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"));
            }
        }
コード例 #2
0
 // GET: User/Details/5
 public ActionResult Details(int id)
 {
     using (BLLContext ctx = new BLLContext())
     {
         UserBO user = ctx.GetUserByID(id);
         return(View(user));
     }
 }
コード例 #3
0
        // 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"));
            }
        }
コード例 #4
0
 // 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"));
     }
 }