public GetAllToppingsResponse GetAll() { var response = new GetAllToppingsResponse(); var getAllToppingsResponse = _toppingRepository.GetAll(); if (getAllToppingsResponse.HasError) { response.AddError(getAllToppingsResponse.Error); return(response); } response.Toppings = getAllToppingsResponse.Toppings.ConvertAll(x => new ToppingModel { Id = x.Id, Name = x.Name }); return(response); }
public PizzaQuery(IPizzaRepository pizzaRepository, IToppingRepository toppingRepository) { // this.AuthorizeWith("Authorized"); Field <PizzaType>( "pizza", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "id" } ), resolve: context => this.loadPizza(context, pizzaRepository)); Field <ListGraphType <PizzaType> >( "pizzas", resolve: context => this.loadAllPizzas(context, pizzaRepository)) .AuthorizeWith("LoggedIn"); Field <ListGraphType <ToppingType> >( "toppings", resolve: context => toppingRepository.GetAll()); }