Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              IConfiguration _configuration,
                              CupcakeContext cupcakeContext)
        {
            this._configuration = _configuration;
            cupcakeContext.Database.EnsureDeleted();
            cupcakeContext.Database.EnsureCreated();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseStaticFiles();

            app.UseRouting();

            /*
             * app.UseEndpoints(endpoints =>
             * {
             *  endpoints.MapGet("/", async context =>
             *  {
             *      await context.Response.WriteAsync("Hello World!");
             *  });
             * });
             */
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "CupcakeRoute",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Cupcake", action = "Index" },
                    constraints: new { id = "[0-9]+" });
            });
        }
Example #2
0
        public void Configure(IApplicationBuilder app, CupcakeContext cupcakeContext)
        {
            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "CupcakeRoute",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Cupcake", action = "Index" },
                    constraints: new { id = "[0-9]+" });
            });
        }
Example #3
0
 public void Configure(IApplicationBuilder app, CupcakeContext cupcakeContext)
 {
     cupcakeContext.Database.EnsureDeleted();            ///error
     cupcakeContext.Database.EnsureCreated();
     app.UseStaticFiles();
     app.UseRouting();
     app.UseEndpoints(endpoints => {
         endpoints.MapControllerRoute(
             name: "default",
             pattern: "{controller=Cupcake}/{action=Index}/{id?}");
         endpoints.MapRazorPages();
     });
 }
Example #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, CupcakeContext ctx)
        {
            app.UseStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "CupcakeRoute",
                    pattern: "{controller=Cupcake}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });
        }
Example #5
0
 public CupcakeRepository(CupcakeContext cupcakeContext)
 {
     _context = cupcakeContext;
 }