public async Task <ActionResult <IdentityResourceApiDto> > Get(int id) { var identityResourceDto = await _identityResourceService.GetIdentityResourceAsync(id); var identityResourceApiModel = identityResourceDto.ToIdentityResourceApiModel <IdentityResourceApiDto>(); return(Ok(identityResourceApiModel)); }
public async Task <ActionResult <IdentityResourceDto> > GetIdentityResource(int id) { if (!ModelState.IsValid) { return(BadRequest(ModelStateErrors)); } return(await _identityResourceService.GetIdentityResourceAsync(id)); }
private void SetupIdentityResources() { FieldAsync <IdentityResourceType>("IdentityResource", arguments: new QueryArguments( new QueryArgument <IntGraphType> { Name = "id" } ), resolve: async context => { if (context.HasArgument("id")) { var id = context.GetArgument <int>("id"); var identityResourceDto = await _identityResourceService.GetIdentityResourceAsync(id); var identityResourceApiModel = identityResourceDto.ToIdentityResourceApiModel <IdentityResourceApiDto>(); return(identityResourceApiModel); } return(new ArgumentNullException("id")); } ); FieldAsync <ListGraphType <IdentityResourceType> >("IdentityResources", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "search", DefaultValue = "" }, new QueryArgument <IntGraphType> { Name = "page", DefaultValue = 1 }, new QueryArgument <IntGraphType> { Name = "pageSize", DefaultValue = 10 } ), resolve: async context => { var searchText = context.GetArgument <string>("search"); var page = context.GetArgument <int>("page"); var pageSize = context.GetArgument <int>("pageSize"); var identityResourcesDto = await _identityResourceService.GetIdentityResourcesAsync(searchText, page, pageSize); var identityResourcesApiDto = identityResourcesDto.ToIdentityResourceApiModel <IdentityResourcesApiDto>(); return(identityResourcesApiDto.IdentityResources); } ); FieldAsync <IdentityResourceType>("IdentityResourceProperty", arguments: new QueryArguments( new QueryArgument <IntGraphType> { Name = "id" } ), resolve: async context => { if (context.HasArgument("id")) { var id = context.GetArgument <int>("id"); var identityResourcePropertiesDto = await _identityResourceService.GetIdentityResourcePropertyAsync(id); var identityResourcePropertyApiDto = identityResourcePropertiesDto.ToIdentityResourceApiModel <IdentityResourcePropertyApiDto>(); return(identityResourcePropertyApiDto); } return(new ArgumentNullException("id")); } ); FieldAsync <ListGraphType <IdentityResourceType> >("IdentityResourcesProperties", arguments: new QueryArguments( new QueryArgument <IntGraphType> { Name = "id" }, new QueryArgument <IntGraphType> { Name = "page", DefaultValue = 1 }, new QueryArgument <IntGraphType> { Name = "pageSize", DefaultValue = 10 } ), resolve: async context => { if (context.HasArgument("id")) { var id = context.GetArgument <int>("id"); var page = context.GetArgument <int>("page"); var pageSize = context.GetArgument <int>("pageSize"); var identityResourcePropertiesDto = await _identityResourceService.GetIdentityResourcePropertiesAsync(id, page, pageSize); var identityResourcePropertiesApiDto = identityResourcePropertiesDto.ToIdentityResourceApiModel <IdentityResourcePropertiesApiDto>(); return(identityResourcePropertiesApiDto.IdentityResourceProperties); } return(new ArgumentNullException("id")); } ); }
public async Task <ActionResult <JsonResponse <IdentityResource> > > Get(string name) { var resource = await _identityResourceService.GetIdentityResourceAsync(name); return(JsonResponse(resource)); }