public EmployeeType(warehouseContext _db) { Name = "Employee"; Field(x => x.Id); Field(x => x.first_name); Field(x => x.last_name); }
public BuildingType(warehouseContext _db, 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 <AddressType>( "address", arguments: new QueryArguments( new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => { var address = db.Addresses .FirstOrDefault(i => i.Id == context.Source.address_id); return(address); }); Field <ListGraphType <BatteryType> >( "batteries", // arguments: // new QueryArguments( // new QueryArgument<IntGraphType> { Name = "id" }), resolve: context => { var batteries = db.Batteries .Where(ss => ss.building_id == context.Source.Id) .ToListAsync(); return(batteries); }); Field <ListGraphType <BuildingsDetailType> >( "buildingsDetails", arguments: new QueryArguments( new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => { var buildingDetails = db.BuildingsDetails .Where(ss => ss.building_id == context.Source.Id) .ToListAsync(); return(buildingDetails); }); }
public FactInterventionQuery(warehouseContext db, dbContext _db) { Field <FactInterventionType>( "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 <EmployeeType>( "employeeQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var employee = _db .Employees .ToListAsync(); return(employee); }); Field <ListGraphType <EmployeeType> >( "allemployeesQuery", //arguments:// new QueryArguments( // new QueryArgument<IdGraphType> { Name = "id"}), resolve: context => { //var id = context.GetArgument<long>("id"); var employees = _db .Employees .ToListAsync(); return(employees); }); Field <BuildingType>( "buildingQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var building = _db .Buildings .Include(x => x.Address) //.Include(x => x.Customer) .FirstOrDefault(i => i.Id == id); return(building); }); Field <ListGraphType <ElevatorType> >( "elevatorQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var elevators = _db .Elevators .Where(_ => _.column_id == id) .ToListAsync(); return(elevators); }); Field <ListGraphType <ColumnType> >( "columnQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var columns = _db .Columns .Where(_ => _.battery_id == id) .ToListAsync(); return(columns); }); Field <ListGraphType <BatteryType> >( "batteryQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var batteries = _db .Batteries .Where(_ => _.building_id == id) .ToListAsync(); return(batteries); }); Field <CustomerType>( "customerQuery", arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <long>("id"); var customers = _db .Customers .FirstOrDefault(i => i.Id == id); return(customers); }); }