public GraphQLQuery(CalorieCounterContext efContext) { Field <ProductType>("product", arguments: new QueryArguments(new QueryArgument <IdGraphType> { Name = "id" }, new QueryArgument <StringGraphType> { Name = "name" }), resolve: context => { var id = context.GetArgument <Guid>("id"); var name = context.GetArgument <string>("name"); return(efContext.Products.FirstOrDefault(x => x.Id == id || x.Name.Contains(name))); } ); Field <ListGraphType <ProductType> >("products", arguments: new QueryArguments(new QueryArgument <StringGraphType> { Name = "name" }, new QueryArgument <IntGraphType> { Name = "takeFirst" }), resolve: context => { var takeFirst = context.GetArgument <int>("takeFirst", 5); var name = context.GetArgument <string>("name", ""); return(efContext.Products.Where(x => x.Name.Contains(name)).Take(takeFirst).ToList()); } ); }
public FoodLogService(CalorieCounterContext context, IProductService productService) { _productService = productService; _context = context; }
public ProductService(CalorieCounterContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public UserService(CalorieCounterContext context, IPasswordHasher <User> passwordHasher, IJwtHandler jwtHandler) { _context = context; _passwordHasher = passwordHasher; _jwtHandler = jwtHandler; }