Beispiel #1
0
        public ActionResult B_UserEdit(int id)
        {
            B_User        user  = B_User.GetEntityByID(id);
            List <B_Role> roles = B_Role.GetUserRoles(user.UserName);
            B_Role        role  = (roles != null && roles.Count > 0) ? roles[0] : null;

            user.RoleID = role == null ? 0 : role.ID;
            return(View(user));
        }
Beispiel #2
0
        //
        // GET: /Home/

        public ActionResult Index(string url)
        {
            try
            {
                BaseAuthorizeModel auth = BaseAuthorizeHelper.GetAuthorizeModel(this.HttpContext);
                if (string.IsNullOrWhiteSpace(auth.TempDataMsg) == false)
                {
                    TempData["Msg"] = auth.TempDataMsg;
                }
                if (auth.IsAuthorize == false)
                {
                    string userAgent = Request.UserAgent;
                    return(RedirectToAction("Login", "Home", new { url = Request.Url.ToString() }));
                }
                B_User        user  = auth.CurrentSYSUser;
                List <B_Menu> menus = B_Menu.GetShowMenus();

                if (user.UserName != WeConfig.robot)
                {
                    menus.RemoveAll(m => m.IsRobot);
                }

                List <B_Role>       roles     = B_Role.GetUserRoles(user.UserName);
                List <B_MenuRights> rolerignt = B_MenuRights.GetRoleUser(roles[0].ID);
                ViewData["role"]     = (roles != null && roles.Count > 0) ? roles[0] : null;
                ViewData["menus"]    = menus;
                ViewData["url"]      = url;
                ViewData["UserRole"] = rolerignt;

                return(View(user));
            }
            catch (Exception ex)
            {
                DAL.Log.Instance.Write(ex.ToString());
                return(View(ErrorPage.ViewName, new ErrorPage {
                    Message = ex.ToString()
                }));
            }
        }