示例#1
0
        public UserAdministrationController(
            IMembershipSettings membershipSettings,
            IUserService userService,
            IPasswordService passwordService,
            IRolesService rolesService,
            ISmtpClient smtpClient, IMembershipService service, IFormsAuthentication formsAuth,
            IMEmployeeRepository mEmployeeRepository,
            IMMenuRepository mMenuRepository,
            ITPrivilegeRepository tPrivilegeRepository)
        {
            _membershipSettings = membershipSettings;
            _userService        = userService;
            _passwordService    = passwordService;
            _rolesService       = rolesService;
            _smtpClient         = smtpClient;
            FormsAuth           = formsAuth ?? new FormsAuthenticationService();
            MembershipService   = service ?? new AccountMembershipService();


            Check.Require(mEmployeeRepository != null, "mEmployeeRepository may not be null");
            Check.Require(mMenuRepository != null, "mMenuRepository may not be null");
            Check.Require(tPrivilegeRepository != null, "tPrivilegeRepository may not be null");

            this._mEmployeeRepository  = mEmployeeRepository;
            this._mMenuRepository      = mMenuRepository;
            this._tPrivilegeRepository = tPrivilegeRepository;
        }
示例#2
0
        public static PrivilegeViewModel Create(string userName, IMMenuRepository mMenuRepository, ITPrivilegeRepository tPrivilegeRepository)
        {
            var viewModel = new PrivilegeViewModel();
            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add("UserName", userName);
            IList <TPrivilege> privileges = tPrivilegeRepository.FindAll(param);

            var menus = from menu in mMenuRepository.GetAll()
                        where menu.MenuParent == null
                        select new PrivilegeViewModel()
            {
                Menu      = menu,
                HasAccess = CheckAccess(menu, privileges),
                children  = (from child in menu.MenuChildren
                             select new PrivilegeViewModel()
                {
                    Menu = child,
                    HasAccess = CheckAccess(menu, privileges),
                }).ToArray()
            };

            return(viewModel);
        }