using API.Helpers; using API.Middleware; using Core.Interfaces; using Infrastructure.Data; using Microsoft.EntityFrameworkCore; using Microsoft.OpenApi.Models; namespace API { public class Startup { private readonly IConfiguration _config; public Startup(IConfiguration config) { _config = config; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddDbContext(x => x.UseSqlite(_config.GetConnectionString("DefaultConnection"))); services.AddScoped(); services.AddScoped(typeof(IGenericRepository<>), (typeof(GenericRepository<>))); services.AddAutoMapper(typeof(MappingProfiles)); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "WebAPIv5", Version = "v1" }); }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseMiddleware(); if (env.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebAPIv5 v1")); } app.UseStatusCodePagesWithReExecute("/errors/{0}"); app.UseHttpsRedirection(); app.UseRouting(); app.UseStaticFiles(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } }