55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using API_Proje.Services;
|
|
|
|
namespace API_Proje
|
|
{
|
|
public class Startup
|
|
{
|
|
public Startup(IConfiguration configuration)
|
|
{
|
|
Configuration = configuration;
|
|
}
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
[Obsolete]
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_2);
|
|
|
|
// Add DbContext
|
|
services.AddDbContext<ProductionOrdersAPIContext>(options =>
|
|
options.UseInMemoryDatabase(databaseName: "ProductionOrdersDatabase"));
|
|
|
|
// Register services
|
|
services.AddTransient<IProductionOrderRepository, InMemoryProductionOrderRepository>();
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
if (env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
else
|
|
{
|
|
app.UseExceptionHandler("/Error");
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseRouting();
|
|
app.UseAuthorization();
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapControllers();
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
}
|