コード例 #1
0
ファイル: Startup.cs プロジェクト: ahmedzakaria432/OdeToFood
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, OdeToFoodDBContext context, ILogger <Startup> logger)
        {
            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();
            }
            //app.Use(SayHelloMiddleWare);
            var DropRecreate = false;

            if (DropRecreate)
            {
                string FileName = $"{ Directory.GetCurrentDirectory()}\\DataAccess\\OdeToFoodDbBackUp.sql";

                Backup(FileName, logger);


                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                ExecBackup(FileName, logger);
            }



            app.UseHttpsRedirection();

            app.Use(Next => {
                return(async ctx => {
                    if (ctx.Request.Path.StartsWithSegments("/hello"))
                    {
                        ctx.Response.Redirect("/Resturants/List");
                    }
                    else
                    {
                        await Next.Invoke(ctx);
                    }
                });
            });
            app.UseStaticFiles();
            app.UseNodeModules();
            app.UseCookiePolicy();
            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapControllers();
            });
        }
コード例 #2
0
 public SqlRestaurantData(OdeToFoodDBContext context)
 {
     _context = context;
 }
コード例 #3
0
 public RestaurantsController(OdeToFoodDBContext context)
 {
     _context = context;
 }
コード例 #4
0
 public SqlResturantData(OdeToFoodDBContext db)
 {
     this.db = db;
 }
コード例 #5
0
 public IndexModel(OdeToFoodDBContext context)
 {
     _context = context;
 }