public async Task CreateAsync() { //Arrange var input = new IdentityRoleCreateDto { Name = Guid.NewGuid().ToString("N").Left(8) }; //Act var result = await _roleAppService.CreateAsync(input); //Assert result.Id.ShouldNotBe(Guid.Empty); result.Name.ShouldBe(input.Name); var role = await _roleRepository.GetAsync(result.Id); role.Name.ShouldBe(input.Name); }
public async Task <IActionResult> PostCreateAsync( [FromBody] IdentityRoleCreateDto role, [FromQuery] string permissions) { role.IsPublic = true; var res = await _IdentityRoleAppService .CreateAsync(role); if (res != null) { var ignorePermission = new List <string> { ASPCoreMVCPermissions.GroupName, "AbpIdentity", "FeatureManagement", "AbpTenantManagement" }; var newPermissions = permissions?.Split(",").ToList() ?? new List <string>(); if (newPermissions.Any(x => x == ASPCoreMVCPermissions.UserManager.Default)) { newPermissions.Add("AbpIdentity.Roles"); newPermissions.Add("AbpIdentity.Roles.Create"); newPermissions.Add("AbpIdentity.Roles.Update"); newPermissions.Add("AbpIdentity.Roles.Delete"); newPermissions.Add("AbpIdentity.Roles.ManagePermissions"); newPermissions.Add("AbpIdentity.Users"); newPermissions.Add("AbpIdentity.Users.Create"); newPermissions.Add("AbpIdentity.Users.Update"); newPermissions.Add("AbpIdentity.Users.Delete"); newPermissions.Add("AbpIdentity.Users.ManagePermissions"); } // Thêm quyền mới foreach (var permission in newPermissions) { if (!ignorePermission.Any(x => x.Equals(permission, StringComparison.OrdinalIgnoreCase))) { await _PermissionManager.SetForRoleAsync(res.Name, permission, true); } } return(Json(new ResponseWrapper <IdentityRoleDto>().SuccessReponseWrapper(res, "Create new role successful"))); } else { return(Json(new ResponseWrapper <IdentityRoleDto>().ErrorReponseWrapper(default, "Create new role successful", 400)));
/// <summary> /// Creates the specified input. /// </summary> /// <param name="input">The input.</param> /// <returns>Task<IdentityRoleDto>.</returns> public virtual Task <IdentityRoleDto> Create(IdentityRoleCreateDto input) { return(_appService.CreateAsync(input)); }
public async Task <IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input) { return(await _identityRoleAppService.CreateAsync(input)); }