Example #1
0
        public InterventionQuery(cindy_okino_warehouseContext db)
        {
            Field <InterventionType>(
                name: "intervention",

                arguments: new QueryArguments(
                    new QueryArgument <IntGraphType> {
                Name = "id"
            }),                                             ///MAYBE IdGraphType

                resolve: context =>
            {
                var id = context.GetArgument <int>("id"); ///MAYBE int

                var intervention = db
                                   .FactInterventions
                                   .FirstOrDefault(i => i.Id == id);
                return(intervention);
            });

            Field <ListGraphType <InterventionType> >(
                name: "interventions",

                resolve: context =>
            {
                var interventions = db.FactInterventions;
                return(interventions.ToList());
            });
        }
Example #2
0
        public EmployeeType(cindy_okino_warehouseContext _db)
        {
            Name = "Employee";

            Field(x => x.Id);
            Field(x => x.FirstName);
            Field(x => x.LastName);
            Field <ListGraphType <FactInterventionType> >(
                "interventions",

                arguments:
                new QueryArguments(
                    new QueryArgument <IntGraphType> {
                Name = "id"
            }),

                resolve: context =>
            {
                var interventions = _db.FactInterventions
                                    .Where(ss => ss.EmployeeId == context.Source.Id)
                                    .ToListAsync();

                return(interventions);
            });
        }
 public GraphQLController(cindy_okino_warehouseContext db) => _db = db;
Example #4
0
 public FactInterventionsController(cindy_okino_warehouseContext context)
 {
     _context = context;
 }
        public FactInterventionQuery(cindy_okino_warehouseContext db, cindy_okino_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(_ => _.ColumnId == 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(_ => _.BatteryId == 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(_ => _.BuildingId == 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);
            });
        }
Example #6
0
        public BuildingType(cindy_okino_warehouseContext _db, cindy_okino_dbContext db)
        {
            Name = "Building";

            Field(x => x.Id);
            Field(x => x.TectContactPhone);
            Field(x => x.TectContactEmail);
            Field(x => x.TectContactName);
            Field(x => x.AdmContactPhone);
            Field(x => x.AdmContactMail);
            Field(x => x.AdmContactName);
            Field(x => x.AddressId, nullable: true);
            Field(x => x.CustomerId, 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.AddressId);

                return(address);
            });
            Field <ListGraphType <FactInterventionType> >(
                "interventions",

                arguments:
                new QueryArguments(
                    new QueryArgument <IntGraphType> {
                Name = "id"
            }),

                resolve: context =>
            {
                var interventions = _db.FactInterventions
                                    .Where(ss => ss.BuildingId == context.Source.Id)
                                    .ToListAsync();

                return(interventions);
            });
            Field <ListGraphType <BatteryType> >(
                "batteries",

                // arguments:
                //   new QueryArguments(
                //     new QueryArgument<IntGraphType> { Name = "id" }),

                resolve: context =>
            {
                var batteries = db.Batteries
                                .Where(ss => ss.BuildingId == 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.BuildingId == context.Source.Id)
                                      .ToListAsync();

                return(buildingDetails);
            });
        }