private async Task <object> ResolveOrdersConnectionAsync(IMediator mediator, IResolveConnectionContext <object> context) { var query = context.ExtractQuery <SearchOrderQuery>(); context.CopyArgumentsToUserContext(); var allCurrencies = await _currencyService.GetAllCurrenciesAsync(); //Store all currencies in the user context for future resolve in the schema types context.SetCurrencies(allCurrencies, query.CultureName); var authorizationResult = await _authorizationService.AuthorizeAsync(context.GetCurrentPrincipal(), query, new CanAccessOrderAuthorizationRequirement()); if (!authorizationResult.Succeeded) { throw new AuthorizationError($"Access denied"); } var response = await mediator.Send(query); foreach (var customerOrderAggregate in response.Results) { context.SetExpandedObjectGraph(customerOrderAggregate); } return(new PagedConnection <CustomerOrderAggregate>(response.Results, query.Skip, query.Take, response.TotalCount)); }
private async Task <object> ResolveConnectionAsync(IMediator mediator, IResolveConnectionContext <object> context) { var first = context.First; var skip = Convert.ToInt32(context.After ?? 0.ToString()); var query = context.GetCartQuery <SearchCartQuery>(); query.Skip = skip; query.Take = first ?? context.PageSize ?? 10; query.Sort = context.GetArgument <string>("sort"); query.Filter = context.GetArgument <string>("filter"); query.IncludeFields = context.SubFields.Values.GetAllNodesPaths().ToArray(); context.CopyArgumentsToUserContext(); var authorizationResult = await _authorizationService.AuthorizeAsync(context.GetCurrentPrincipal(), query, new CanAccessCartAuthorizationRequirement()); if (!authorizationResult.Succeeded) { throw new ExecutionError($"Access denied"); } var response = await mediator.Send(query); foreach (var cartAggregate in response.Results) { context.SetExpandedObjectGraph(cartAggregate); } return(new PagedConnection <CartAggregate>(response.Results, skip, Convert.ToInt32(context.After ?? 0.ToString()), response.TotalCount)); }
private static async Task <object> ResolveConnectionAsync(IMediator mediator, IResolveConnectionContext <DynamicProperty> context) { int.TryParse(context.After, out var skip); var query = context.GetDynamicPropertiesQuery <SearchDynamicPropertyDictionaryItemQuery>(); query.PropertyId = context.Source.Id; query.Skip = skip; query.Take = context.First ?? context.PageSize ?? 10; query.Sort = context.GetArgument <string>("sort"); query.Filter = context.GetArgument <string>("filter"); context.CopyArgumentsToUserContext(); var response = await mediator.Send(query); return(new PagedConnection <DynamicPropertyDictionaryItem>(response.Results, query.Skip, query.Take, response.TotalCount)); }
private async Task <object> ResolveOrdersConnectionAsync(IMediator mediator, IResolveConnectionContext <object> context) { var first = context.First; var skip = Convert.ToInt32(context.After ?? 0.ToString()); var request = new SearchOrderQuery { Skip = skip, Take = first ?? context.PageSize ?? 10, Filter = context.GetArgument <string>("filter"), Sort = context.GetArgument <string>("sort"), CultureName = context.GetArgument <string>(nameof(Currency.CultureName).ToCamelCase()), CustomerId = context.GetArgumentOrValue <string>("userId") }; context.CopyArgumentsToUserContext(); var allCurrencies = await _currencyService.GetAllCurrenciesAsync(); //Store all currencies in the user context for future resolve in the schema types context.SetCurrencies(allCurrencies, request.CultureName); var authorizationResult = await _authorizationService.AuthorizeAsync(context.GetCurrentPrincipal(), request, new CanAccessOrderAuthorizationRequirement()); if (!authorizationResult.Succeeded) { throw new ExecutionError($"Access denied"); } var response = await mediator.Send(request); foreach (var customerOrderAggregate in response.Results) { context.SetExpandedObjectGraph(customerOrderAggregate); } return(new PagedConnection <CustomerOrderAggregate>(response.Results, skip, Convert.ToInt32(context.After ?? 0.ToString()), response.TotalCount)); }