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, ILoggerFactory loggerFactory, IGreeter greeter)
        {
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // we can use this two line of code.
            //app.UseDefaultFiles();
            //app.UseStaticFiles();

            //Instead of that two line we can you just one line
            app.UseFileServer();
            app.UseMvc(ConfigureRoutes);

            app.Run(async(context) =>
            {
                // throw new System.Exception("error");
                //var greetings = Configuration["greetings"];
                var greetings = greeter.GetAllGreetings();
                await context.Response.WriteAsync(greetings);
            });
        }
        public ViewResult Index()
        {
            var restaurent = new RestaurentViewModel();

            restaurent.Restaurents     = _restaurentData.GetAll();
            restaurent.CurrentGreeting = _greeter.GetAllGreetings();
            return(View(restaurent));
        }