2022-05-10 16:49:42 -07:00
|
|
|
using API.Helpers;
|
2022-05-09 17:07:59 -07:00
|
|
|
using Core.Interfaces;
|
2022-05-09 18:31:09 -07:00
|
|
|
using Infrastructure.Data;
|
2022-05-09 14:41:15 -07:00
|
|
|
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<StoreContext>(x => x.UseSqlite(_config.GetConnectionString("DefaultConnection")));
|
2022-05-09 17:07:59 -07:00
|
|
|
services.AddScoped<iProductRepository, ProductRepository>();
|
2022-05-10 15:45:47 -07:00
|
|
|
services.AddScoped(typeof(IGenericRepository<>), (typeof(GenericRepository<>)));
|
2022-05-10 16:49:42 -07:00
|
|
|
services.AddAutoMapper(typeof(MappingProfiles));
|
2022-05-09 14:41:15 -07:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebAPIv5 v1"));
|
|
|
|
}
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
{
|
|
|
|
endpoints.MapControllers();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|