示例#1
0
 public static RoleData ToData(RoleDto dto)
 {
   return new RoleData()
   {
     Id = dto.Id,
     Text = dto.Text,
   };
 }
示例#2
0
 public bool UserIsInRole(RoleDto role)
 {
     return(User.Roles != null && User.Roles.Any(r => r == role.DisplayName));
 }
示例#3
0
 protected Task OnResetSearchAsync(RoleDto dto)
 {
     dto.RoleName = null;
     return(Task.CompletedTask);
 }
示例#4
0
        public async Task <IActionResult> AddRole(RoleDto dto)
        {
            var result = await _roleService.CreateRole(dto);

            return(Ok(result));
        }
示例#5
0
 public Task <bool> Add(RoleDto model)
 {
     throw new NotImplementedException();
 }
示例#6
0
 private void ValidateRole(RoleDto roleDto)
 {
     //throw new NotImplementedException();
 }
示例#7
0
 public void AddRole(RoleDto role)
 {
     _repository.AddRole(RoleDtoToRoleConvert(role));
 }
示例#8
0
        public async Task <IActionResult> Save(RoleDto model)
        {
            await _service.SaveAsync(model);

            return(JsonData(true));
        }
示例#9
0
 public bool CreateRole(RoleDto role)
 {
     throw new NotImplementedException();
 }
示例#10
0
 public UserDto()
 {
     Role = new RoleDto();
 }
示例#11
0
 public void Update(RoleDto role)
 {
     roleServiceClient.Update(role);
 }
示例#12
0
        public RoleDto Get(string id = null, string name = null)
        {
            RoleDto role = roleServiceClient.Get(id, name);

            return(role);
        }
示例#13
0
        public string Create(RoleDto role)
        {
            string id = roleServiceClient.Create(role);

            return(id);
        }
示例#14
0
        public ActionResult <RoleDto> AddRole(RoleDto roleDto)
        {
            RoleDto createdRole = _roleService.AddRole(roleDto);

            return(CreatedAtAction(nameof(GetRoleById), new { id = createdRole.Id }, createdRole));
        }
示例#15
0
 private RoleDto GetRole(int roleId)
 {
     return(RoleDto.FromRoleInfo(RoleController.Instance.GetRoleById(PortalId, roleId)));
 }
        private static void PersistRoleToDataStore(IGalleryServerRole role)
        {
            // Update the existing role or insert if it doesn't exist.
            using (GspContext ctx = new GspContext())
            {
                RoleDto roleDto = ctx.Roles.Find(role.RoleName);

                if (roleDto == null)
                {
                    roleDto = new RoleDto
                                            {
                                                RoleName = role.RoleName,
                                                AllowViewAlbumsAndObjects = role.AllowViewAlbumOrMediaObject,
                                                AllowViewOriginalImage = role.AllowViewOriginalImage,
                                                AllowAddChildAlbum = role.AllowAddChildAlbum,
                                                AllowAddMediaObject = role.AllowAddMediaObject,
                                                AllowEditAlbum = role.AllowEditAlbum,
                                                AllowEditMediaObject = role.AllowEditMediaObject,
                                                AllowDeleteChildAlbum = role.AllowDeleteChildAlbum,
                                                AllowDeleteMediaObject = role.AllowDeleteMediaObject,
                                                AllowSynchronize = role.AllowSynchronize,
                                                HideWatermark = role.HideWatermark,
                                                AllowAdministerGallery = role.AllowAdministerGallery,
                                                AllowAdministerSite = role.AllowAdministerSite
                                            };

                    ctx.Roles.Add(roleDto);
                }
                else
                {
                    roleDto.AllowViewAlbumsAndObjects = role.AllowViewAlbumOrMediaObject;
                    roleDto.AllowViewOriginalImage = role.AllowViewOriginalImage;
                    roleDto.AllowAddChildAlbum = role.AllowAddChildAlbum;
                    roleDto.AllowAddMediaObject = role.AllowAddMediaObject;
                    roleDto.AllowEditAlbum = role.AllowEditAlbum;
                    roleDto.AllowEditMediaObject = role.AllowEditMediaObject;
                    roleDto.AllowDeleteChildAlbum = role.AllowDeleteChildAlbum;
                    roleDto.AllowDeleteMediaObject = role.AllowDeleteMediaObject;
                    roleDto.AllowSynchronize = role.AllowSynchronize;
                    roleDto.HideWatermark = role.HideWatermark;
                    roleDto.AllowAdministerGallery = role.AllowAdministerGallery;
                    roleDto.AllowAdministerSite = role.AllowAdministerSite;
                }

                ctx.SaveChanges();
            }
        }
示例#17
0
 public bool UpdateRole(RoleDto model)
 {
     throw new NotImplementedException();
 }
        public async Task <IActionResult> UpdateRole([FromBody] RoleDto roleDto)
        {
            var result = await _authorizationAdminService.UpdateRole(roleDto);

            return(FromReply(result));
        }
示例#19
0
        //[AbpAuthorize(PermissionNames.Pages_Users)]
        //[DontWrapResult] //不需要AbpJsonResult
        public async Task <JsonResult> Update([FromBody] RoleDto input)
        {
            var role = await _roleAppService.Update(input);

            return(Json(role));
        }
示例#20
0
 public void UpdateRole(RoleDto role)
 {
     _repository.UpdateRole(RoleDtoToRoleConvert(role));
 }
 /// <summary>
 /// Creates a new role.
 /// </summary>
 /// <remarks>
 /// Required permissions: Roles.Create.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='roleDto'>
 /// </param>
 public static RoleDto Post(this IRoles operations, RoleDto roleDto)
 {
     return(operations.PostAsync(roleDto).GetAwaiter().GetResult());
 }
示例#22
0
 public ActionResult Edit(string moudleId, string menuId, string btnId, RoleDto dto)
 {
     roleService.Update(dto);
     return(RedirectToAction("Index", RouteData.Values));
 }
 /// <summary>
 /// Edits a role.
 /// </summary>
 /// <remarks>
 /// Required permissions: Roles.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='roleDto'>
 /// </param>
 public static RoleDto PutById(this IRoles operations, int id, RoleDto roleDto)
 {
     return(operations.PutByIdAsync(id, roleDto).GetAwaiter().GetResult());
 }
示例#24
0
 public ActionResult Edit(RoleDto[] dtos)
 {
     dtos.CheckNotNull("dtos" );
     OperationResult result = IdentityContract.EditRoles(dtos);
     return Json(result.ToAjaxResult());
 }
 /// <summary>
 /// Edits a role.
 /// </summary>
 /// <remarks>
 /// Required permissions: Roles.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='roleDto'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <RoleDto> PutByIdAsync(this IRoles operations, int id, RoleDto roleDto, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.PutByIdWithHttpMessagesAsync(id, roleDto, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
示例#26
0
        public IActionResult UpdateRole(RoleDto dto)
        {
            var result = _roleService.UpdateRole(dto);

            return(Ok(result));
        }
示例#27
0
        public async Task <ActionResult <RoleDto> > GetRoleByIdAsync([FromRoute] string id)
        {
            RoleDto role = await Mediator.Send(new GetRoleByIdQuery { RoleId = id });

            return(Ok(role));
        }
示例#28
0
 public bool UserIsInRole(RoleDto role)
 {
     return(User.RoleNames != null && User.RoleNames.Any(r => r == role.NormalizedName));
 }
示例#29
0
 public void Update(RoleDto dto)
 {
     this.Update <RoleDto, Role>(dto);
 }
示例#30
0
        public async Task <bool> AddRole(RoleDto roleDto)
        {
            var role = Role.Create(roleDto.Name);

            return(await this._roleRep.CreateAsync(role));
        }
示例#31
0
        public void Create(RoleDto dto)
        {
            var role = new Role(dto.Name);

            this._documentStore.Save(role);
        }
示例#32
0
 public async Task <ApiResponse> CreateRoleAsync([FromBody] RoleDto roleDto)
 => await _adminManager.CreateRoleAsync(roleDto);
示例#33
0
 public static IdentityRole ToEntity(this RoleDto role)
 {
     return(Mapper.Map <IdentityRole>(role));
 }
示例#34
0
        /// <summary>
        /// Return a collection representing the roles for all galleries. If no matching objects
        /// are found in the data store, an empty collection is returned.
        /// </summary>
        /// <returns>
        /// Returns a collection object representing the roles for all galleries.
        /// </returns>
        public static IEnumerable<RoleDto> GetRoles()
        {
            List<RoleDto> roles = new List<RoleDto>();

            using (IDataReader dr = GetCommandRoles().ExecuteReader(CommandBehavior.CloseConnection))
            {
                string previousRoleName = null;
                RoleDto role = null;
                while (dr.Read())
                {
                    // SQL:
                    //SELECT r.RoleName, r.AllowViewAlbumsAndObjects, r.AllowViewOriginalImage, r.AllowAddChildAlbum,
                    //  r.AllowAddMediaObject, r.AllowEditAlbum, r.AllowEditMediaObject, r.AllowDeleteChildAlbum,
                    //  r.AllowDeleteMediaObject, r.AllowSynchronize, r.HideWatermark, r.AllowAdministerGallery,
                    //  r.AllowAdministerSite, ra.FKAlbumId
                    //FROM dbo.[dnn_gs_Role] r LEFT OUTER JOIN dbo.[dnn_gs_Role_Album] ra ON r.RoleName = ra.FKRoleName
                    //ORDER BY r.RoleName
                    string roleName = dr.GetString(0);

                    if (!roleName.Equals(previousRoleName, StringComparison.OrdinalIgnoreCase))
                    {
                        previousRoleName = roleName;

                        role = new RoleDto
                                        {
                                            RoleName = roleName,
                                            AllowViewAlbumsAndObjects = dr.GetBoolean(1),
                                            AllowViewOriginalImage = dr.GetBoolean(2),
                                            AllowAddChildAlbum = dr.GetBoolean(3),
                                            AllowAddMediaObject = dr.GetBoolean(4),
                                            AllowEditAlbum = dr.GetBoolean(5),
                                            AllowEditMediaObject = dr.GetBoolean(6),
                                            AllowDeleteChildAlbum = dr.GetBoolean(7),
                                            AllowDeleteMediaObject = dr.GetBoolean(8),
                                            AllowSynchronize = dr.GetBoolean(9),
                                            HideWatermark = dr.GetBoolean(10),
                                            AllowAdministerGallery = dr.GetBoolean(11),
                                            AllowAdministerSite = dr.GetBoolean(12)
                                        };

                        roles.Add(role);

                        role.RoleAlbums = new HashSet<RoleAlbumDto>();
                    }

                    if (role == null)
                    {
                        throw new DataException("The variable 'role' was null. This should never happen.");
                    }

                    if (!dr.IsDBNull(13))
                    {
                        role.RoleAlbums.Add(new RoleAlbumDto
                                                                    {
                                                                        FKRoleName = roleName,
                                                                        FKAlbumId = dr.GetInt32(13)
                                                                    });
                    }
                }
            }

            return roles;
        }
示例#35
0
 public ActionResult AddRole(RoleDto model)
 {
     using (var proxy = new UserServiceClient())
     {
         proxy.CreateRoles(new List<RoleDto> { model }.ToArray());
         return RedirectToSuccess("添加账户角色成功!", "Roles", "Admin");
     }
 }