public async Task <ActionResult> PutRoles([FromBody] CreateOrUpdateRoleInput input) { var identityResult = await _roleAppService.EditRoleAsync(input); if (identityResult.Succeeded) { return(Ok()); } return(BadRequest(identityResult.Errors.Select(e => new NameValueDto(e.Code, e.Description)))); }
public async Task <ActionResult> CreateOrUpdateRole([FromBody] CreateOrUpdateRoleInput input) { if (input.Role.Id == Guid.Empty) { await _roleAppService.AddRoleAsync(input); } else { await _roleAppService.EditRoleAsync(input); } return(Ok(new { success = true })); }
public async Task <ActionResult> CreateOrUpdateRole([FromBody] CreateOrUpdateRoleInput input) { IdentityResult identityResult; if (input.Role.Id == Guid.Empty) { identityResult = await _roleAppService.AddRoleAsync(input); } else { identityResult = await _roleAppService.EditRoleAsync(input); } if (identityResult.Succeeded) { return(Ok()); } return(BadRequest(identityResult.Errors.Select(e => new NameValueDto(e.Code, e.Description)))); }
public async void Should_Edit_Role() { var testRole = await CreateAndGetTestRoleAsync(); var input = new CreateOrUpdateRoleInput { Role = new RoleDto { Id = testRole.Id, Name = "TestRoleName_Edited_" + Guid.NewGuid() }, GrantedPermissionIds = new List <Guid> { DefaultPermissions.MemberAccess.Id } }; await _roleAppService.EditRoleAsync(input); var editedTestRole = await _dbContext.Roles.FindAsync(testRole.Id); Assert.Contains("TestRoleName_Edited_", editedTestRole.Name); Assert.Contains(editedTestRole.RolePermissions, rp => rp.PermissionId == DefaultPermissions.MemberAccess.Id); }