public EmployeesType(warehouse_developmentContext _db) { Name = "Employee"; Field(x => x.Id); Field(x => x.first_name); Field(x => x.last_name); }
public BuildingsType(warehouse_developmentContext _db, RailsApp_development_dbContext db) { Name = "Building"; Field(x => x.Id); Field(x => x.technical_contact_phone_for_the_building); Field(x => x.technical_contact_email_for_the_building); Field(x => x.full_name_of_the_technical_contact_for_the_building); Field(x => x.phone_number_of_the_building_administrator); Field(x => x.email_of_the_administrator_of_the_building); Field(x => x.full_name_of_the_building_administrator); Field(x => x.address_id, nullable: true); Field(x => x.customer_id, nullable: true); //Field(x => x.Address, type: typeof(AddressType)); Field <AddressesType>( "address", arguments: new QueryArguments( new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => { var address = db.Address .FirstOrDefault(i => i.Id == context.Source.Address.Id); return(address); }); Field <ListGraphType <BatteriesType> >( "batteries", // arguments: // new QueryArguments( // new QueryArgument<IntGraphType> { Name = "id" }), resolve: context => { var batteries = db.Battery .Where(ss => ss.building_id == context.Source.Id) .ToListAsync(); return(batteries); }); Field <ListGraphType <BuildingsDetailsType> >( "buildingsDetails", arguments: new QueryArguments( new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => { var buildingDetails = db.BuildingsDetail .Where(ss => ss.building_id == context.Source.Id) .ToListAsync(); return(buildingDetails); }); }
public FactInterventionQuery(warehouse_developmentContext db, RailsApp_development_dbContext _db) { Field <FactInterventionsType>( "interventionQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var intervention = db .FactInterventions .FirstOrDefault(i => i.Id == id); return(intervention); }); Field <EmployeesType>( "employeeQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var employee = _db .Employee .ToListAsync(); return(employee); }); Field <ListGraphType <EmployeesType> >( "allemployeesQuery", //arguments:// new QueryArguments( // new QueryArgument<IdGraphType> { Name = "id"}), resolve: context => { //var id = context.GetArgument<long>("id"); var employees = _db .Employee .ToListAsync(); return(employees); }); Field <BuildingsType>( "buildingQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var building = _db .Building .Include(x => x.Address) //.Include(x => x.Customer) .FirstOrDefault(i => i.Id == id); return(building); }); Field <ListGraphType <ElevatorsType> >( "elevatorQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var elevators = _db .Elevator .Where(_ => _.column_id == id) .ToListAsync(); return(elevators); }); Field <ListGraphType <ColumnsType> >( "columnQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var columns = _db .Column .Where(_ => _.battery_id == id) .ToListAsync(); return(columns); }); Field <ListGraphType <BatteriesType> >( "batteriesQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var batteries = _db .Battery .Where(_ => _.building_id == id) .ToListAsync(); return(batteries); }); Field <CustomersType>( "customerQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var customers = _db .Customer .FirstOrDefault(i => i.Id == id); return(customers); }); }