コード例 #1
0
        private void CreateRolePermission(Role role, int permissionId)
        {
            RolePermission rolePermission = new RolePermission();

              rolePermission.RoleId = role.Id;
              rolePermission.PermissionId = permissionId;
              this.Storage.GetRepository<IRolePermissionRepository>().Create(rolePermission);
        }
コード例 #2
0
 public RoleViewModel Build(Role role)
 {
     return new RoleViewModel()
       {
     Id = role.Id,
     Name = role.Name,
     Position = role.Position
       };
 }
コード例 #3
0
        public Role Map(CreateOrEditViewModel createOrEdit)
        {
            Role role = new Role();

              if (createOrEdit.Id != null)
            role = this.handler.Storage.GetRepository<IRoleRepository>().WithKey((int)createOrEdit.Id);

              role.Code = createOrEdit.Code;
              role.Name = createOrEdit.Name;
              role.Position = createOrEdit.Position;
              return role;
        }
コード例 #4
0
        public UserRoleViewModel Build(User user, Role role)
        {
            UserRole userRole = null;

              if (user != null)
            userRole = this.handler.Storage.GetRepository<IUserRoleRepository>().WithKey(user.Id, role.Id);

              return new UserRoleViewModel()
              {
            Role = new RoleViewModelBuilder(this.handler).Build(role),
            IsAssigned = userRole != null
              };
        }
コード例 #5
0
        public RolePermissionViewModel Build(Role role, Permission permission)
        {
            RolePermission rolePermission = null;

              if (role != null)
            rolePermission = this.handler.Storage.GetRepository<IRolePermissionRepository>().WithKey(role.Id, permission.Id);

              return new RolePermissionViewModel()
              {
            Permission = new PermissionViewModelBuilder(this.handler).Build(permission),
            IsAssigned = rolePermission != null
              };
        }
コード例 #6
0
        private void CreateRolePermissions(Role role)
        {
            foreach (string key in this.Request.Form.Keys)
              {
            if (key.StartsWith("permission") && this.Request.Form[key] == true.ToString().ToLower())
            {
              string permissionId = key.Replace("permission", string.Empty);

              this.CreateRolePermission(role, int.Parse(permissionId));
            }
              }

              this.Storage.Save();
        }
コード例 #7
0
 private void CreateOrEditRolePermissions(Role role)
 {
     this.DeleteRolePermissions(role);
       this.CreateRolePermissions(role);
 }
コード例 #8
0
        private void DeleteRolePermissions(Role role)
        {
            foreach (RolePermission rolePermission in this.Storage.GetRepository<IRolePermissionRepository>().FilteredByRoleId(role.Id))
            this.Storage.GetRepository<IRolePermissionRepository>().Delete(rolePermission);

              this.Storage.Save();
        }
コード例 #9
0
 public IEnumerable<RolePermissionViewModel> GetRolePermissions(Role role = null)
 {
     return this.handler.Storage.GetRepository<IPermissionRepository>().All().Select(
     p => new RolePermissionViewModelBuilder(this.handler).Build(role, p)
       );
 }