public void AddTestDefinitions() { #region CustomerService FieldAsync <GetAllCustomerResponseGraphType>("customers", description: "Returns a collection of CustomerDto", arguments: new QueryArguments() { new QueryArgument <StringGraphType>() { Name = "Filter" }, new QueryArgument <StringGraphType>() { Name = "Sort" }, new QueryArgument <IntGraphType>() { Name = "Skip" }, new QueryArgument <IntGraphType>() { Name = "Take" }, }, resolve: async context => { var httpContext = context.RequestServices.GetRequiredService <IHttpContextAccessor>().HttpContext; var authorizationService = context.RequestServices.GetRequiredService <IAuthorizationService>(); var authorizationResult = await authorizationService.AuthorizeAsync(httpContext.User, "AdminUser"); if (!authorizationResult.Succeeded) { throw new UnauthorizedAccessException("Policy Authorization Required"); } var request = new GetAllRequest(); request.Filter = context.GetArgument <string>("filter", default(string)); request.Sort = context.GetArgument <string>("sort", default(string)); request.Skip = context.GetArgument <int?>("skip", default(int?)); request.Take = context.GetArgument <int?>("take", default(int?)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.ICustomerServiceClient>(); return(await service.GetAll(request)); } ); FieldAsync <CustomerDtoGraphType>("customer", description: "Returns one CustomerDto by Id", arguments: new QueryArguments() { new QueryArgument <GuidGraphType>() { Name = "Id" }, }, resolve: async context => { var httpContext = context.RequestServices.GetRequiredService <IHttpContextAccessor>().HttpContext; var authorizationService = context.RequestServices.GetRequiredService <IAuthorizationService>(); var authorizationResult = await authorizationService.AuthorizeAsync(httpContext.User, "AdminUser"); if (!authorizationResult.Succeeded) { throw new UnauthorizedAccessException("Policy Authorization Required"); } var request = new GetCustomerRequest(); request.Id = context.GetArgument <Guid>("id", default(Guid)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.ICustomerServiceClient>(); return(await service.Get(request)); } ); #endregion CustomerService #region CustomerEventService FieldAsync <GetAllCustomerEventResponseGraphType>("customerEvents", description: "Returns a collection of CustomerEventDto", arguments: new QueryArguments() { new QueryArgument <StringGraphType>() { Name = "Filter" }, new QueryArgument <StringGraphType>() { Name = "Sort" }, new QueryArgument <IntGraphType>() { Name = "Skip" }, new QueryArgument <IntGraphType>() { Name = "Take" }, }, resolve: async context => { var httpContext = context.RequestServices.GetRequiredService <IHttpContextAccessor>().HttpContext; if (!httpContext.User.Identity.IsAuthenticated) { throw new UnauthorizedAccessException("Authentication Required"); } var request = new GetAllRequest(); request.Filter = context.GetArgument <string>("filter", default(string)); request.Sort = context.GetArgument <string>("sort", default(string)); request.Skip = context.GetArgument <int?>("skip", default(int?)); request.Take = context.GetArgument <int?>("take", default(int?)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.ICustomerEventServiceClient>(); return(await service.GetAll(request)); } ); FieldAsync <CustomerEventDtoGraphType>("customerEvent", description: "Returns one CustomerEventDto by Id", arguments: new QueryArguments() { new QueryArgument <GuidGraphType>() { Name = "Id" }, }, resolve: async context => { var httpContext = context.RequestServices.GetRequiredService <IHttpContextAccessor>().HttpContext; if (!httpContext.User.Identity.IsAuthenticated) { throw new UnauthorizedAccessException("Authentication Required"); } var request = new GetCustomerEventRequest(); request.Id = context.GetArgument <Guid>("id", default(Guid)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.ICustomerEventServiceClient>(); return(await service.Get(request)); } ); #endregion CustomerEventService #region OrderService FieldAsync <DowndloadImageResponseGraphType>("OrderService_DownloadImage", arguments: new QueryArguments() { new QueryArgument <StringGraphType>() { Name = "Name" }, }, resolve: async context => { var request = new DownloadImageRequest(); request.Name = context.GetArgument <string>("name", default(string)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.IOrderServiceClient>(); return(await service.DownloadImage(request)); } ); FieldAsync <GetAllNamesResponseGraphType>("ordernames", resolve: async context => { var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.IOrderServiceClient>(); return(await service.GetAllNames()); } ); FieldAsync <OrderNamesDtoGraphType>("OrderService_OrderName", arguments: new QueryArguments() { new QueryArgument <StringGraphType>() { Name = "Id" }, }, resolve: async context => { var request = new GetOrderNameRequest(); request.Id = context.GetArgument <string>("id", default(string)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.IOrderServiceClient>(); return(await service.GetOrderName(request)); } ); FieldAsync <GetAllOrderResponseGraphType>("orders", description: "Returns a collection of OrderDto", arguments: new QueryArguments() { new QueryArgument <StringGraphType>() { Name = "Filter" }, new QueryArgument <StringGraphType>() { Name = "Sort" }, new QueryArgument <IntGraphType>() { Name = "Skip" }, new QueryArgument <IntGraphType>() { Name = "Take" }, }, resolve: async context => { var request = new GetAllRequest(); request.Filter = context.GetArgument <string>("filter", default(string)); request.Sort = context.GetArgument <string>("sort", default(string)); request.Skip = context.GetArgument <int?>("skip", default(int?)); request.Take = context.GetArgument <int?>("take", default(int?)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.IOrderServiceClient>(); return(await service.GetAll(request)); } ); FieldAsync <OrderDtoGraphType>("order", description: "Returns one OrderDto by Id", arguments: new QueryArguments() { new QueryArgument <GuidGraphType>() { Name = "Id" }, }, resolve: async context => { var request = new GetOrderRequest(); request.Id = context.GetArgument <Guid>("id", default(Guid)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.IOrderServiceClient>(); return(await service.Get(request)); } ); #endregion OrderService #region OrderStateService FieldAsync <GetAllOrderStateResponseGraphType>("orderStates", description: "Returns a collection of OrderStateDto", arguments: new QueryArguments() { new QueryArgument <StringGraphType>() { Name = "Filter" }, new QueryArgument <StringGraphType>() { Name = "Sort" }, new QueryArgument <IntGraphType>() { Name = "Skip" }, new QueryArgument <IntGraphType>() { Name = "Take" }, }, resolve: async context => { var httpContext = context.RequestServices.GetRequiredService <IHttpContextAccessor>().HttpContext; if (!httpContext.User.IsInRole("admin")) { throw new UnauthorizedAccessException("Roles Authorization Required"); } var request = new GetAllRequest(); request.Filter = context.GetArgument <string>("filter", default(string)); request.Sort = context.GetArgument <string>("sort", default(string)); request.Skip = context.GetArgument <int?>("skip", default(int?)); request.Take = context.GetArgument <int?>("take", default(int?)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.IOrderStateServiceClient>(); return(await service.GetAll(request)); } ); FieldAsync <OrderStateDtoGraphType>("orderState", description: "Returns one OrderStateDto by Id", arguments: new QueryArguments() { new QueryArgument <IntGraphType>() { Name = "Id" }, }, resolve: async context => { var httpContext = context.RequestServices.GetRequiredService <IHttpContextAccessor>().HttpContext; if (!httpContext.User.IsInRole("admin")) { throw new UnauthorizedAccessException("Roles Authorization Required"); } var request = new GetOrderStateRequest(); request.Id = context.GetArgument <int>("id", default(int)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.IOrderStateServiceClient>(); return(await service.Get(request)); } ); #endregion OrderStateService #region ReadOnlyEntityService FieldAsync <GetAllReadOnlyEntityResponseGraphType>("readOnlyEntities", description: "Returns a collection of ReadOnlyEntityDto", arguments: new QueryArguments() { new QueryArgument <StringGraphType>() { Name = "Filter" }, new QueryArgument <StringGraphType>() { Name = "Sort" }, new QueryArgument <IntGraphType>() { Name = "Skip" }, new QueryArgument <IntGraphType>() { Name = "Take" }, }, resolve: async context => { var httpContext = context.RequestServices.GetRequiredService <IHttpContextAccessor>().HttpContext; if (!httpContext.User.IsInRole("admin")) { throw new UnauthorizedAccessException("Roles Authorization Required"); } var request = new GetAllRequest(); request.Filter = context.GetArgument <string>("filter", default(string)); request.Sort = context.GetArgument <string>("sort", default(string)); request.Skip = context.GetArgument <int?>("skip", default(int?)); request.Take = context.GetArgument <int?>("take", default(int?)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.IReadOnlyEntityServiceClient>(); return(await service.GetAll(request)); } ); FieldAsync <ReadOnlyEntityDtoGraphType>("readOnlyEntity", description: "Returns one ReadOnlyEntityDto by Id", arguments: new QueryArguments() { new QueryArgument <IntGraphType>() { Name = "Id" }, }, resolve: async context => { var httpContext = context.RequestServices.GetRequiredService <IHttpContextAccessor>().HttpContext; if (!httpContext.User.IsInRole("admin")) { throw new UnauthorizedAccessException("Roles Authorization Required"); } var request = new GetReadOnlyEntityRequest(); request.Id = context.GetArgument <int>("id", default(int)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.IReadOnlyEntityServiceClient>(); return(await service.Get(request)); } ); #endregion ReadOnlyEntityService #region SoftDeleteOrderService FieldAsync <GetAllSoftDeleteOrderResponseGraphType>("softDeleteOrders", description: "Returns a collection of SoftDeleteOrderDto", arguments: new QueryArguments() { new QueryArgument <StringGraphType>() { Name = "Filter" }, new QueryArgument <StringGraphType>() { Name = "Sort" }, new QueryArgument <IntGraphType>() { Name = "Skip" }, new QueryArgument <IntGraphType>() { Name = "Take" }, }, resolve: async context => { var request = new GetAllRequest(); request.Filter = context.GetArgument <string>("filter", default(string)); request.Sort = context.GetArgument <string>("sort", default(string)); request.Skip = context.GetArgument <int?>("skip", default(int?)); request.Take = context.GetArgument <int?>("take", default(int?)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.ISoftDeleteOrderServiceClient>(); return(await service.GetAll(request)); } ); FieldAsync <SoftDeleteOrderDtoGraphType>("softDeleteOrder", description: "Returns one SoftDeleteOrderDto by Id", arguments: new QueryArguments() { new QueryArgument <GuidGraphType>() { Name = "Id" }, }, resolve: async context => { var request = new GetSoftDeleteOrderRequest(); request.Id = context.GetArgument <Guid>("id", default(Guid)); var service = context.RequestServices.GetRequiredService <global::Cybtans.Tests.Clients.ISoftDeleteOrderServiceClient>(); return(await service.Get(request)); } ); #endregion SoftDeleteOrderService }
public Task <ReadOnlyEntityDto> Get(int id, [FromQuery] GetReadOnlyEntityRequest __request) { __request.Id = id; return(_service.Get(__request)); }