Exemplo n.º 1
0
        private void PrepareCustomerRoleModel(CustomerRoleModel model)
        {
            var parentRoles = _roleService.GetAllRoles(showHidden: true,
                                                       parentIds: new List <int> {
                0
            }
                                                       );

            if (model == null)
            {
                model = new CustomerRoleModel();
            }

            model.AvailableParentRole.Add(new SelectListItem
            {
                Selected = model.ParentId == 0,
                Text     = "顶级角色",
                Value    = "0",
            });

            foreach (var item in parentRoles.Items)
            {
                model.AvailableParentRole.Add(new SelectListItem {
                    Selected = model.ParentId == item.Id,
                    Text     = item.RoleName,
                    Value    = item.Id.ToString(),
                });
            }
        }
Exemplo n.º 2
0
        protected virtual void PrepareCustomerListModel(CustomerListModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("customerRole");
            }

            var roles = _roleService.GetAllRoles(showHidden: true);

            foreach (var customerRole in roles.Items)
            {
                model.AvailableRoles.Add(new SelectListItem
                {
                    Text  = customerRole.RoleName,
                    Value = customerRole.Id.ToString(),
                });
            }
        }