using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using shopapp.data.Concrete.EfCore;
using shopapp.data.Abstract;
using shopapp.business.Abstract;
using shopapp.business.Concrete;
namespace shopapp.webui
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IProductRepository, EfCoreProductRepository>();
services.AddScoped<IProductService, ProductManager>();
//mvc
//razor pages
services.AddControllersWithViews();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseStaticFiles(); //wwwroot
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "node_modules")),
RequestPath = "/modules"
});
if (env.IsDevelopment())
{
SeedDatabase.Seed();
app.UseDeveloperExceptionPage();
}
app.UseRouting();
//localhost:5000
//localhost:5000/home
//localhost:5000/products
//localhost:5000/category/5
//localhost:5000/products/list/2
//Aşağıdaki şemaya göre gelen istekleri değerlendirebiliyoruz. Bir controllerın birden fazla actionı olabilir.
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"
);
});
}
}
}