private async Task <object> GetUsersInvitedForTenantAsync(dynamic input) { await RequiresAccess() .WithPrincipalIdExpansion(_ => PrincipalId) .ExecuteAsync(CancellationToken.None); bool.TryParse(Request.Query["allusers"], out bool allUsers); try { var result = await _userInviteController.GetUsersInvitedForTenantAsync(TenantId, allUsers); return(Negotiate .WithModel(result) .WithStatusCode(HttpStatusCode.OK)); } catch (NotFoundException) { return(Response.NotFound(ResponseReasons.NotFoundUser)); } catch (ValidationFailedException ex) { return(Response.BadRequestValidationFailed(ex.Errors)); } catch (Exception ex) { Logger.Error($"Failed to get users invited for tenant {TenantId} due to an error", ex); return(Response.InternalServerError(ResponseReasons.InternalServerErrorCreateUser)); } }
public async Task GetInvitedUsersForTenantIfUsersExists() { const int count = 5; var tenantId = Guid.NewGuid(); _userInviteRepositoryMock.SetupCreateItemQuery(o => Enumerable.Range(0, count).Select(i => new UserInvite { TenantId = tenantId })); var result = await _controller.GetUsersInvitedForTenantAsync(tenantId, true); Assert.Equal(count, result.List.Count); }