Esempio n. 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, CarvedRockDbContext dbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();
            dbContext.Seed();
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            CarvedRockDbContext dbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseGraphQL <CarvedRockSchema>();
            app.UseGraphQLPlayground(new GraphQLPlaygroundOptions());
            //app.UseMvc();
            dbContext.Seed();
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CarvedRockDbContext dbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();
            app.UseGraphQL <CarvedRockSchema>();
            app.UseGraphQLPlayground(new GraphQLPlaygroundOptions());
            //dbContext.Seed();
            app.UseRouting();

            //app.UseAuthorization();

            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }
Esempio n. 4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CarvedRockDbContext dbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            // GraphQL
            app.UseCors(builder =>
                        builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());

            app.UseGraphQL <CarvedRockSchema>();     // In argument we can specify the endpoint URI, /GraphQl default

            // Sets up the default GraphQL playground at /ui/Playground
            // Project properties -> Debug -> Launch browser -> ui/Playground (starts the browser with the playground)
            app.UseGraphQLPlayground(new GraphQLPlaygroundOptions());   // To play around with the API without web application ( web app not yet created )


            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseCookiePolicy();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            // Fill the database
            dbContext.Seed();
        }
 public ProductReviewRepository(CarvedRockDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Esempio n. 6
0
 public PolicyRepository(CarvedRockDbContext dbContext)
 {
     _dbContext = dbContext;
 }
 public ProductReviewRepository(CarvedRockDbContext context) : base(context)
 {
     _context = context;
 }
Esempio n. 8
0
 public Repository(CarvedRockDbContext context)
 {
     _context = context;
 }
Esempio n. 9
0
 public void Configure(IApplicationBuilder app, CarvedRockDbContext dbContext)
 {
     app.UseGraphQL <CarvedRockSchema>();
     app.UseGraphQLPlayground(new GraphQLPlaygroundOptions());
     dbContext.Seed();
 }
 public ProductRepository(CarvedRockDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
Esempio n. 11
0
 public OwnerRepository(CarvedRockDbContext dbContext)
 {
     _dbContext = dbContext;
 }
 public ProductReviewRepository(CarvedRockDbContext dbContext)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
 }
Esempio n. 13
0
        public CarvedRockQuery(ProductRepository productRepository, CarvedRockDbContext db)
        {
            Field <ListGraphType <ProductType> >(
                "products",
                resolve: context => productRepository.GetAll()
                );

            Field <ProductType>(
                "product",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }
                                              ),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(productRepository.GetOne(id));
            }
                );

            Field <ListGraphType <ProductType> >(
                "productsnew",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "first"
            },
                    new QueryArgument <StringGraphType> {
                Name = "orderby"
            }
                    ),
                resolve: context =>
            {
                var first    = context.GetArgument <int>("first");
                var order_by = context.GetArgument <string>("orderby");

                var query = db.Products.Take(first);
                if (order_by == "id")
                {
                    query = query.OrderBy(order => order.Id);
                }
                else
                {
                    query = query.OrderBy(order => order.Name);
                }

                return(query);

                // return productRepository.GetOne(id);
            }
                );

            Field <ListGraphType <NewProductType> >(
                "anytype",
                resolve: context =>
            {
                return(db.Products.Select(product => new NewProduct {
                    Id = product.Id, Name = product.Name
                }));
            }
                );
        }
Esempio n. 14
0
 public CustomerRepository(CarvedRockDbContext dbContext)
 {
     _dbContext = dbContext;
 }