Exemplo n.º 1
0
        public IActionResult Index()
        {
            var model = new HomeIndexViewModel
            {
                Restaurants    = _restaurantData.GettAll(),
                CurrentMessage = _greeting.GetMessageOfDay()
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public IActionResult Index()
        {
            GreetingModel model = new GreetingModel()
            {
                CreateDate = DateTime.Now,
                Id         = 1,
                Message    = _greeting.GetMessageOfDay()
            };

            return(View(model));
        }
Exemplo n.º 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeting greetings)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync(greetings.GetMessageOfDay());
            });
        }
Exemplo n.º 4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeting greetings, ILogger <Startup> logger)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Use(next =>
            {
                return(async context =>
                {
                    logger.Log(LogLevel.Information, "Entrada");
                    if (context.Request.Path.StartsWithSegments("/log"))
                    {
                        await context.Response.WriteAsync("Hit!!");
                        logger.LogInformation("Requisição tradada");
                    }
                    else
                    {
                        await next(context);
                        logger.LogInformation("Requisição invalida");
                    }
                });
            });

            app.UseWelcomePage("/bemvindo");

            app.UseMvc(ConfigurationRountes);

            app.Run(async(context) =>
            {
                var messageOfDay             = greetings.GetMessageOfDay();
                context.Response.ContentType = "text/plain";
                await context.Response.WriteAsync(messageOfDay);
            });
        }